2

I want to assign a role to a user after the user confirms his/her email.

How do I do this?

1
  • Please mention your Drupal version (6 or 7 ?) Commented Oct 23, 2012 at 18:43

2 Answers 2

2

You'll want to take a look at Rules and LoginToboggan (as per this answer on Drupal Answers).

Rules will allow you to add a "trigger", such as adding a role to a user, and LoginToboggan will provide the "trigger" for when the account is validated.

0

You can use hook_user_login(&$edit, $account) which is called from user_login_finalize().

When $edit parameter is empty is because is called from user_pass_reset() menu callback:

// user_login_finalize() also updates the login timestamp of the // user, which invalidates further use of the one-time login link. user_login_finalize(); 

This example should work:

function MYMODULE_user_login(&$edit, $account) { if (empty($edit)) { // @todo Add role to $account->roles array } } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.