I have 2 roles:

  • Customer
  • Moderator

I have created a Rule:

Event. On account creation

Condition. If user has role: Moderator (and checked reverse, so when user doesn't have a role Moderator it should return TRUE), also as data selector i chose "account"

Action. Assign role: Customer, selector "account"

However, when i logged in with a user with role Moderator and create a new user with role Moderator it automatically adds the role customer as well. So my condition isn't working?

UPDATE I have tried in conditions: [site:current-user], still it adds the "Customer" role to a newly created account with a role Moderator by Moderator

  • Rules for user accounts are very specific. You need to ensure that you specify the newly created account as the one you want to modify.
    – filmoreha
    Mar 26 '14 at 8:38
  • How can i check that? On action? Mar 26 '14 at 8:41
  • You can add a third condition to check that "account" does not have the moderator account. Basically combine what you had with the answer I posted. Good luck!
    – filmoreha
    Mar 26 '14 at 9:53

Sorry, ignore my last comment.

You need a condition of "user as role" set to "site:current-user". Then select the role that is required which is "moderator". Leave everything else unchanged and save.

You need an action of "add role" This action defaults to "account" so leave it as is. Select the role you want to add, and save.

  • That said, not entirely sure of your use case, but I think the condition is unnecessary. Whether a user is registering themselves or a person with admin rights registers them, you could just set the necessary role on account save.
    – filmoreha
    Mar 26 '14 at 8:52
  • I have tried in condition site:current-user and in action account. Still when i am logged as moderator it adds this role: customer to it, even if i set a Moderator role to a newly created account. Mar 26 '14 at 9:01
  • I just tested this and it works for me. Make sure you are not negating/reversing the site:current-user condition, otherwise it won't work.
    – filmoreha
    Mar 26 '14 at 9:17
  • Also of note, only people with administer users can create accounts. And you can set the role on the user creation page, so I am not entirely sure why you need this rule.
    – filmoreha
    Mar 26 '14 at 9:21
  • Well it works if i remove the checkmark "Reverse". But i need that "Reverse" functionality. Because when i am logged as Moderator and i will create another moderator, i don't want him to have the customer role as well. Mar 26 '14 at 9:25

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.