I have 2 roles (driver, owner) with very different permissions on my site. I want to allow Facebook Connect during registration, so I am resigned to a 2-step registration process:

  1. Register as a basic user via Facebook Connect or standard Drupal registration.
  2. Basic user selects the appropriate role.

I will auto-assign the role "basic" upon registration and present a block to all users of the basic role which asks them to select Driver or Owner as their account type. Upon clicking the appropriate link, their user account will be updated with the new role. I can use Rules to remove the "basic" role whenever an account has been saved with one of the other roles.

How can I assign a role using a link displayed in a block?

Thank you.

  • Have you looked at the drupal.org/project/profile2_regpath or drupal.org/project/autoassignrole modules? They can assign roles based upon the path used to create/register the account.
    – Jimajamma
    Dec 10, 2013 at 20:00
  • Yes I have, thanks. There may be a way to use these, but I have a conflict with Facebook Connect in the mix. If I could use Facebook Connect to fill in the appropriate fields on a registration form without saving the form, I think the registration path method would work. So far, I only see the option to create the account using FB Connect. Dec 10, 2013 at 20:05

2 Answers 2


I solved this by using the Rules module and 2 basic pages. Not a very scalable solution, but works in this limited application.

  1. User registers using Facebook Connect or the core Drupal registration process.
  2. The new user with the "basic" role is redirected (via Rules) to a "select your role" page with links to a "Welcome new driver" page and a "Welcome new owner" page.
  3. Upon viewing the node, "Welcome new driver/owner", with the role "basic" a rule is triggered which sets the desired new role, removes the "basic" role and triggers role-specific welcome email.

I don't know this will help you or not:

  1. Create two pages.

  2. 1-page callback will be a registration form. This can be a facebook reg: Link to discussion or Drupal reg. form. Then redirect the registered user to second page.

  3. 2-page, simple form which requires user to choose a role. You can get an info here: user_roles()
  4. On second form submission, you can update user account information with user_save() an redirect him anywhere you want...

Notice, that I did not mention how will be handled the user role control. Because a user can simply skip the second page. You can store some kind of flag in $_SESSION or even better in database table which verifies that user actually chose a role or not. If not then redirect him back to second page.

  • Thank you. This is the approach I'm going for. I am unfamiliar with how to build the form (on the second page) for selecting a role. I know I can handle users who have skipped the second page via Rules. Could you point me in the right direction for building a role-section form? Thanks again! Dec 11, 2013 at 14:06
  • @StevenDunwoody drupal.org/project/examples - the best place to learn drupal module development. You can find nice examples about Form API. Just install it and test it how forms are work then you can learn how that form was built by its source code. p/s: After installing the examples module, links will be available in Navigation block
    – xurshid29
    Dec 11, 2013 at 14:15

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.