To create an admin user using WP-CLI (WordPress Command Line Interface), follow these steps:
- Open your terminal or command prompt.
- Navigate to your WordPress installation directory. This is the directory where your WordPress files are located.
- Run the command to create a new user:
Use the wp user create command followed by the username, email, and other necessary details. For example, to create a user with the username adminuser, email admin@example.com, and set their role to administrator, you would use the following command:wp user create adminuser admin@example.com --role=administrator --user_pass=yourpassword
Here’s a breakdown of the command:
wp user create: The WP-CLI command to create a new user.adminuser: The username for the new user.admin@example.com: The email address for the new user.--role=administrator: Assigns theadministratorrole to the new user.--user_pass=yourpassword: Optional. Sets the password for the new user. Replaceyourpasswordwith a strong password of your choice. If not provided, WordPress will assign a default password and include this in the output message.
- Check the output:
After running the command, WP-CLI will output a message confirming the creation of the new user. For example:Success: Created user 3.
This new user will now have administrator privileges and can log in to the WordPress admin dashboard using the provided username and password.
Example
cd /path/to/wordpress wp user create adminuser admin@example.com --role=administrator --user_pass=strongpassword123
Replace /path/to/wordpress with the actual path to your WordPress installation, adminuser with your desired username, `
admin@example.comwith the user's email address, andstrongpassword123` with a strong, secure password.
Additional Options
WP-CLI also provides additional options you can use when creating a user, such as setting the user’s first name, last name, and display name. Here’s an example command that includes these options:
wp user create adminuser admin@example.com --role=administrator --user_pass=strongpassword123 --first_name=Admin --last_name=User --display_name="Admin User"
In this example:
– --first_name=Admin: Sets the first name to “Admin”.
– --last_name=User: Sets the last name to “User”.
– --display_name="Admin User": Sets the display name to “Admin User”.
By using these commands, you can efficiently manage WordPress user accounts directly from the command line.
Managed WordPress Plans
Are you looking for a reliable hosting provider that can help you manage your WordPress websites? Look no further than Ecenica. Our range of WordPress Hosting plans are designed to support multiple websites and provide you with the tools and support you need to manage them all easily.
With our plans, you can create as many WordPress websites as you need, whether you want to use subdomains or domain names. Our platform is optimized for WordPress, so you can expect top-notch performance, security, and speed for all your sites.
WP-Cli is available with SSH and Terminal access to allow you to easily administer your WordPress sites. Sign up for one of our Managed WordPress Hosting plans today and take advantage of our expertise and support. Visit our website to learn more about our plans and get started today!