0

I'm thinking about writing a condition ("has new role(s)") using the Rules module to send an email to user to whom a new role is assigned. I need to know how to actually code this...

If (user has a new role(s)) {

  //   do something

}

I think that, by comparing whether a user has a role before saving and after saving or updating the content, one could tell whether a new role assigned. But I can't figure out how to code it and what API I should use. Please advise.

2
  • Rules has this out of the box, you don't need to code anything. Did you try to solve this yourself? – Aram Boyajyan Apr 12 '14 at 14:37
  • Right, just realised it can be done without coding. Thanks! – Adamtan Apr 13 '14 at 8:47
0

Just found a way to do it without coding. Works well so far.

EVENT: After updating an existing user account

CONDITIONS:

1) Data >> List contains item - LIST: "account-unchanged:roles", ITEM: "Role A" (Check NEGATE)

AND

2) Data >> List contains item - LIST: "account:roles", ITEM: "Role A"

ACTION: Send mail

Ref: http://goo.gl/Pcz2wN

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.