Manage Users with WP CLI

WordPress Command Line Interface (WP CLI) is a powerful tool that streamlines the management of a WordPress site, offering efficient ways to perform various tasks, including user management. Managing users via WP CLI provides flexibility and speed, enabling administrators and developers to handle user-related operations effortlessly.

Being a developer with over a decade of experience, I would highly recommend all the developers to start using WP CLI on daily basis to save time and efforts.

What is WP CLI?

WP CLI is a command-line interface for WordPress, allowing users to interact with their WordPress website directly through the terminal or command prompt. It offers a wide range of commands that perform diverse tasks, significantly enhancing productivity for developers and system administrators.

User Management Basics

User management plays a crucial role in WordPress site administration, involving tasks like creating new users, modifying existing user details, assigning roles, and managing permissions. WP CLI simplifies these operations with its set of commands, making it easier to handle users efficiently.

WP-CLI Commands for User Management

Create Users with wp user create command

The wp user create command facilitates the creation of new users.

wp user create <username> <email> --role=<role>

Replace <username> and <email> with the desired username and email address, respectively. The --role parameter allows you to assign a specific role (e.g., subscriber, editor, administrator) to the new user.

List Users with wp user list command

Use wp user list to display a list of all users registered on your WordPress site.

wp user list

Fetch User Information with wp user get command

Fetch detailed information about a specific user with wp user get.

wp user get <user_id>

Replace <user_id> with the user’s ID or username.

Update User Information with wp user update command

Modify user details such as email address or password using the wp user update command.

wp user update <user_id> --user_email=<new_email> 

This command allows changing the user’s email associated with the given <user_id>.

Changing User Password

Reset a user’s password with wp user update and the --user_pass parameter

wp user update <user_id> --user_pass=<new_password> 

Replace <new_password> with the desired new password.

Deleting User

Remove a user account using the wp user delete command.

wp user delete <user_id> 

Replace <user_id> with the ID of the user account to be deleted.

Bonus Tips

  • Backup Your Database: Before performing any user-related operations, create a backup of your WordPress database to prevent accidental data loss.
  • Use Role Assignments Wisely: Assign appropriate roles to users based on their responsibilities to maintain security and manage access effectively.
  • Regularly Review User Accounts: Periodically review user accounts to remove inactive or unnecessary accounts, enhancing site security and performance.


WP CLI offers a robust set of commands for managing users on WordPress sites efficiently. By leveraging these commands, administrators and developers can streamline user-related tasks, ensuring smoother site management and improved security practices. Understanding and utilizing WP CLI’s user management capabilities can significantly enhance the WordPress site administration experience.

Loved this article? Feel free to share with your friends and colleagues using Twitter or any of your preferred social media.
Mehul Gohil
Mehul Gohil

Mehul Gohil is a Full Stack WordPress developer and an active member of the local WordPress community. For the last 10+ years, he has been developing custom WordPress plugins, custom WordPress themes, third-party API integrations, performance optimization, and custom WordPress websites tailored to the client's business needs and goals.

Articles: 123

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *