Using Drush to manage users
When you need to add an account to Drupal, you will visit the People
page and manually add a new user. Drush provides the complete user management for Drupal, from creation to role assignment, password recovery, and deletion. This workflow allows you to create users easily and provides them with a login without having to enter your Drupal site.
In this recipe, we will create a staff
role with a staffmember
user and log in as that user through Drush.
How to do it…
- Use the
role-create
command to create a new role labeledstaff
:
$ drush role-create staff
Created "staff"
- Use the
role-lists
command to verify that the role was created in Drupal:
$ drush role-list ID Role Label anonymous Anonymous user authenticated Authenticated user administrator Administrator staff Staff
- The
user-create
command will create our user:
$ drush user-create staffmember User ID : 2 User name : staffmember User roles : authenticated User status : 1
- In order to add the role, we will need...