5

I am trying to create a rule that sends an email to the user when a role has been removed from their account. I can't seem to find a rule reaction under User "When role is removed". How do I create a rule to do this?

2
  • You can do it by hook_user. Commented Dec 8, 2012 at 2:27
  • is there no way to get this done just using the rules UI? Commented Dec 10, 2012 at 17:13

1 Answer 1

8
+100

It has to be triggered when a particular role ("subscriber") has been removed. So we can use 2 conditions User has role(s), to check if he had the role before the edit, and that he doesn't have it after the edit :

1st condition : selector "account_unchanged", check the role "subscriber" (here test)

2nd condition : selector "account", check the same role, and negate.

enter image description here

4
  • What if he removed one role and added another one, then your condition will fail. And also what if the OP wanted to trigger the mail whenever the particular role was removed(I think that's what the OP has asked.) However +1 for your approach :) Commented Dec 10, 2012 at 17:37
  • The particular situation is when a user gets their "subscriber" role removed. There are other roles on the site that can be added and removed that shouldn't get this email when those are removed. Commented Dec 10, 2012 at 17:39
  • 2
    If he wants to check that a particular role has been removed, it's even simplier : 1. Add condition "User has role(s)" with account_unchanged and select the role, 2. Add condition "User has role(s)" with account (NOT the unchanged) and NEGATE. Commented Dec 10, 2012 at 17:42
  • I edit my answer to fit to that. Commented Dec 10, 2012 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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