WP-CLI is a powerful command line utility for WordPress, which is included by default with your hosting plan or server. It can be used to perform many of the actions you would normally complete in the WordPress dashboard, such as installing or updating plugins and themes, managing users, making changes to the site configuration, and much more.
Here we cover the steps to create a new user using WP-CLI.
Related Articles
SSH into Shared Server
Remove WordPress User using WP-CLI
Find the Document Root of a Domain
Create User
- Access the server via SSH or using the Terminal in cPanel
- Navigate to the site's document root using the cd command
cd public_html
REPLACE: public_html with your domain's document root if different. See the guide on finding the document root of a domain for guidance. - Run the following command to create a new user
wp user create userna5 user@domain.com --role=administrator
REPLACE: userna5 with the desired username and user@domain.com with the email address you wish to have associated with the new user. If the new user should have a role other than administrator, replace this accordingly. Other roles include editor, author, contributor, and subscriber.
NOTE: You can specify a password by adding --user_pass=<password>. Excluding this will generate a random password. As a best security practice, it is recommended to avoid including a password when running any command when possible.
TIP: Additional options, parameters, and examples of thewp user create
command can be found here.