New role assigned on user account update 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.
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