Skip to main content

The Cheeky Monkey Media Blog

A few words from the apes, monkeys, and various primates that make up the Cheeky Monkey Super Squad.


Advanced Drupal User Management With Drush

Using Drupal’s built-in user interface is great for site managers and is easy to use. But if you’re a drupal developer, you might want to leverage the power of Drush.

For those that don’t know, Drush is a shell interface that allows you to work with drupal via the command line. It allows you to perform tasks quickly using a few small commands rather than clicking away with drupals UI.

Here are a few code snippets to get you started with managing users with Drush:

Create a New Drupal User

To create a new drupal user, use the following command:

  1. drush user-create newuser --mail="[email protected]" --password="secretpassword"

This command creates a new user with the username “newuser” and fills out the password and email address fields.

List Drupal User Information

To view user information, you would use the following command. This command accepts the user name, id or email address.

  1. drush user-information newuser

Block Drupal Users:

Lets face it, not every user is nice. So if you have a fake account or a crazy user, here is how you confront crazy user.

  1. drush user-block crazyuser

This command will block the user with username “crazyuser.” We can also use a comma separated list of user names, ID’s or email address like so:

  1. drush user-block --uid=2,5 --name=newuser,crazyuser,

Add Drupal Role

Just like adding a role using drupals UI, we can do it in drush with the following command:

  1. drush user-add-role "administrator" newuser

Reset User Passwords:

Who can remember all those darn passwords anyway? This command has saved me a few times in the past and will comes in handy:

  1. drush user-password newuser --password="newpassword"

Check out my other blog post for a simple overview of drupal user manament.

Web Development

Would you like to know more about what we do?

View Our Services

Graphic Design Cheeky Monkey

Have a look at some our client work

View Our Work

Cheeky Monkey Discovery

Learn more about Cheeky Monkey Media

About Us