In my latest project client asked me to add extra interface after login where all roles assigned to that user will be shown and user can choose the single role and login by that role only. But i don't know how to do this in drupal. I tried with role switcher and other module but they didn't work for me ? Any suggestions will be appreciated.

Suppose User x have roles A B C D x can choose single role(eg A) after login and do the work only with that role.

1 Answer 1

  • Create a custom module
  • Create a custom form where Admin can whitelist users for certain roles .. Form should have username and roles as a list or checkboxes.
  • Store these settings in database - uid - roles
  • When a user logs in redirect user to a form where he can select user roles from above list
  • On Form Submit, Update user programatically and assign role to the user he selected, remove other roles that user has if any
  • After submitting the form the user roles, which user didn't select will be removed from the roles table, so it will not preserve the other roles identity of the user. I need a solution where role identity must preserve and user must be able to select with other assigned roles next time. May 22, 2014 at 6:06
  • I am talking about custom form if you read my answer correctly... Where you store user - role data in custom table in Drupal database... So you always preserve that association...
    – Anil Sagar
    May 22, 2014 at 6:10

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.