Is there a way to assign an confirmed user role upon account validation/email confirmation?

there is this possibility mentioning logintoboggan:

How do I assign a role to a user after the user's email is confirmed?

My problem is that I am using email registration and genpass (so the user only needs to enter his email) and the modules don't work together.

I'm fairly good with rules and started looking into development. I'm not a programmer though and I don't know how I should implement a corresponding rules condition that checks whether the user has validated his account.

Any suggestions?

1 Answer 1


If you're only allowing the user to login once they validate their email (which would make sense if you're using email confirmations) then you could just create a rule that assigns the role to the user when the user logs in:

{ "rules_add_user_role_at_login" : {
    "LABEL" : "Add user role at login",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_login" : [] },
    "DO" : [
      { "user_add_role" : { "account" : [ "account" ], "roles" : { "value" : { "5" : "5" } } } },
      { "entity_save" : { "data" : [ "account" ], "immediate" : "1" } }

Now, if you're allowing a user to login without having to validate their email (which makes less sense) then you'll need to write a bit of code that hooks into the user reset form and adds the role to the user when that form submits.

  • Thanks for your suggestion and pointing me in the right direction with the user reset form. For now I'm gonna do it like this (though the rule gets triggered whenever a user logs in) because it seems to difficult for me to write such a condition/event
    – user24957
    Dec 20, 2015 at 9:00

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.