---
title: "Creating and Modifying Users With WP-CLI"
source: "https://docs.nexcess.com/hosting/cms/wordpress/troubleshooting/creating-and-modifying-users-with-wp-cli/"
description: "Need to reset a password or create an admin without the dashboard? Use this guide to manage WordPress users directly from the terminal with WP-CLI."
vertical: "Hosting"
date: "2024-03-04"
last_modified: "2026-08-06"
---

# Creating and Modifying Users With WP-CLI

WP-CLI allows you to manage your users from the command line. This can come in handy when modifying privileges and changing roles quickly.

## Manage Users

This set of commands is used to work with the users of a WordPress site.

- **List Users** – You can list all users on your account using this command. ```
    
    wp user list
    ```
    
     The output:
    
    ```
    
    s56@default:~/html$ wp user list 
    +----+------------+--------------+----------------------------+---------------------+---------------+
    | ID | user_login | display_name | user_email                 | user_registered     | roles         |
    +----+------------+--------------+----------------------------+---------------------+---------------+
    | 5  | dougie     | dougie       | djones@lucky7insurance.biz | 2017-09-27 03:36:18 | author        |
    | 6  | janey-e    | janey-e      | janee@yahoo.com            | 2017-09-27 03:43:16 | subscriber    |
    | 3  | joseph-l   | joseph-l     | sample@sourcedns.com       | 2017-09-27 03:14:57 | administrator |
    | 4  | tpreston   | tpreston     | tpreston@fbi.gov           | 2017-09-27 03:34:30 | editor        |
    | 1  | WooComm    | WooComm      | sample@liquidweb.com       | 2017-07-04 03:09:07 | administrator |
    +----+------------+--------------+----------------------------+---------------------+---------------+
    ```
- **Create a User** – There are five default roles within WordPress; administrator, editor, author, contributor, and subscriber. You can read more about these roles in the [WordPress Codex](https://codex.wordpress.org/Roles_and_Capabilities). To create a user, you will use the following command: ```
    
    wp user create USERNAME EMAIL@EXAMPLE.TLD --role=$ROLE
    ```
    
     Example Output:
    
    ```
    
    Success: Created user 2.
    Password: tGnPPoUUHYuR63H(Unj&EzJ^
    ```
    
     Replace Username, email, and $Role to the user you are setting up and the role they will have on your site.
    
    | ### **Note:** |
    |---|
    | Because the password for a new user is in plain text through WP-CLI, have the user change their password after logging in for the first time. |
- **Delete a User** – You can delete a user with this command, but be careful! Any posts that user authored will also disappear with them. To remove a user, use the following command: ```
    
    s56@default:~/html$ wp user delete lwsupport
    --reassign parameter not passed. All associated posts will be deleted. Proceed? [y/n] y
    Success: Removed user 2 from https://woo2.samplesite.com.
    ```

## Modify a User 

There are many ways to modify a user within WP-CLI. You can run the following command to see the options you have available. The most common are listed below.

```

wp help user update
```

- **Change Password** – Need to change a user's password? Just type the following command with the new password and it's done: ```
    
    wp user update $USERNAME --user_pass='PASSWORD'
    ```
    
     Example output:
    
    ```
    
    s56@default:~/html$ wp user update dougie --user_pass='MyNewPassword!'
    Success: Updated user 5.
    ```
- **Change Login Email** – You may need to change the email used to log into your WordPress login. Use the following command: ```
    
    wp user update $USERNAME --user_email=$EXAMPLE@EXAMPLE.TLD
    ```
    
     Example output:
    
    ```
    
    s56@default:~/html$ wp user update tpreston --user_email=tammyp@yahoo.com
    Success: Updated user 4.?
    ```
- **Change Display Name** – Change the name that appears to visitors, it is typically a first and last name. ```
    
    s56@default:~/html$ wp user update tpreston --display_name='Tammy Preston'
    Success: Updated user 4.
    ```
- **Change User Role** – You can change user roles depending on the function you want them to perform within WordPress. 
    1. First, determine the current role: ```
        
        s56@default:~/html$ wp user list 
        +----+------------+--------------+----------------------------+---------------------+---------------+
        | ID | user_login | display_name | user_email                 | user_registered     | roles         |
        +----+------------+--------------+----------------------------+---------------------+---------------+
        | 5  | dougie     | Dougie Jones | djones@lucky7insurance.biz | 2017-09-27 03:36:18 | author        |
        | 1  | WooComm    | WooComm      | sample@liquidweb.com       | 2017-07-04 03:09:07 | administrator |
        +----+------------+--------------+----------------------------+---------------------+---------------+
        ```
    2. Next, update the user with the  **–role** flag: ```
        
        s56@default:~/html$ wp user update dougie --role=editor
        Success: Updated user 5.
        ```
    3. Verify the change: ```
        
        s56@default:~/html$ wp user list 
        +----+------------+--------------+----------------------------+---------------------+---------------+
        | ID | user_login | display_name | user_email                 | user_registered     | roles         |
        +----+------------+--------------+----------------------------+---------------------+---------------+
        | 5  | dougie     | Dougie Jones | djones@lucky7insurance.biz | 2017-09-27 03:36:18 | editor        |
        | 1  | WooComm    | WooComm      | sample@liquidweb.com       | 2017-07-04 03:09:07 | administrator |
        +----+------------+--------------+----------------------------+---------------------+---------------+
        ```
