Once you have installed WP-CLI, there are many things you can do, including adding an admin user with WP-CLI.
If you are interested in using this method, you can follow the steps in this tutorial.
How to Add an Admin User with WP-CLI
Before trying this method, make sure your WP-CLI installation on your server can be run with the command wp. If you do not use the command wp, you can adjust the initial command.
1. Open the WordPress Installation Folder
Make sure you have opened the WordPress installation folder where you want to add the admin user, for example, inside the public_html folder.
cd public_html2. Run the Command to Add a User
The following is the basic command to add a user with the admin role in WP-CLI
wp user create username [email protected] --role=administrator --user_pass="passwordlogin" --first_name=Admin --last_name=User --display_name="Admin User"- wp user create basic WP-CLI command to add a user
- username used to create the username for logging in
- [email protected] email address for the new user login
- –role=administrator the role of the user to be added, you can use subscriber, contributor, author, editor, or administrator
- –user_pass=”passwordlogin” the password used to log in to the new account. passwordlogin needs to be changed to the password you will use
- first_name=Admin account first name (optional)
- –last_name=User account last name (optional)
- –display_name=”Admin User” becomes the name displayed when this new user creates a post
For example, the command to add the user wpgan-com could look like this
wp user create wpgan-com [email protected] --role=administrator --user_pass="pass-wpgan_123" --first_name=WPGan --last_name=Com --display_name="WPGan"When you successfully add a new user, you will receive a success notification
Success: Created user 2.3. Check the User List
To double-check that you have successfully added the user, you can also check it with WP-CLI
wp user listWith that command, you will get a list of accounts that exist in your WordPress.
COMMENTS
Loading...