13

How can I set a user to a specific role via drush? In my case I want to give the role of administrator to the user.

1 Answer 1

22
drush help user-add-role
Add a role to the specified user accounts.

Examples:
 drush user-add-role "power user" 5,user3  Add the "power user" role to the accounts with name, id, or email 5 or user3, uids 2 
 --uid=2,3 --name=someguy,somegal          and 3, names someguy and somegal, and email address of billgates@microsoft.com       
 --mail=billgates@microsoft.com

Arguments:
 role                                      The name of the role to add                                                
 users                                     (optional) A comma delimited list of uids, user names, or email addresses.

Options:
 --mail=<me@example.com>                   A comma delimited list of user mail addresses of users to operate on. 
 --name=<foo>                              A comma delimited list of user names of users to operate on.          
 --uid=<3,5>                               A comma delimited list of uids of users to operate on.

Aliases: urol

So, for your use case:

drush user-add-role administrator USERNAME

2
  • tats too easy! =P ... at least now i know how to do it via sql... lol Aug 13, 2015 at 23:53
  • @duckx but that's like using a back-scratcher to scratch your front Aug 14, 2015 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.