WP-CLI Create User: Easy Guide
Bulletproof Backups for Your WordPress Website
Fortify your business continuity with foolproof WordPress backups. No data loss, no downtime — just secure, seamless operation.
The WP -CLI create user command is an essential tool for WordPress site administrators who need to efficiently manage user accounts for various stakeholders. Maybe you’re adding team members like editors and content writers. You may also have to set up client accounts so they can review and approve website changes.
Once you install WP-CLI on your server, you can create users instantly from the command line with precise control over their roles, passwords, and profile details. In this guide, we’ll walk you through the requirements and step-by-step process for using WP-CLI to create users.
TL;DR: To create a WordPress user via WP-CLI, use this command: wp user create <username> <email> –role=<role> –user_pass=<password>
Prerequisites for WP-CLI Create User
Before you can start using the wp-cli create user command to efficiently manage WordPress accounts, you’ll need to ensure your system is properly configured with the necessary tools and access permissions. These requirements are straightforward but essential for successful user creation via the command line.
- WP-CLI Installed on Server/System: WP-CLI must be installed and accessible from your command line. Ensure you have the latest version for full compatibility.
- SSH/Terminal Access to WordPress Installation: You need the username, password and IP address. You need to have the right permissions to navigate to your WordPress root directory
- Basic Command-Line Familiarity: You should be comfortable navigating directories using cd commands. You need an understanding of file paths and WordPress directory structures.
How to Use WP-CLI Create User Command?
Now that you have the prerequisites to use wp-cli create user command, let’s dive into the actual process of creating WordPress users through the command line. The wp cli create user command is one of many ways to maintain your WordPress site. It makes it simple to create a user in seconds. Here’s how:
- Connect to Your Server: Open your terminal or SSH client and establish a connection to your web server:
ssh username@yourserver.com -p 22
Replace the following:
- username with your SSH username
- yourserver.com with your server IP address
Enter your SSH password when prompted.
- Navigate to WordPress Directory: Change to your WordPress installation directory so WP-CLI can access your wp-config.php file:
cd /var/www/yoursite/public_html
Common WordPress paths:
- /var/www/html (Apache default)
- /home/username/public_html (shared hosting)
- /opt/bitnami/wordpress (Bitnami installs)
Verify location: Run ls -la to confirm you see WordPress files like wp-config.php and wp-content/.
- Execute the WP-CLI Create User Command: Now create your user with the following syntax:
wp user create <username> <email> [options]
Basic Example:
wp user create newuser user@example.com –role=editor
- Verify User Creation: Confirm the user was created successfully:
wp user list --fields=ID,user_login,display_name,roles
You’ll see a response saying that you successfully created a user.
The user data is now stored in your WordPress database (wp_users and wp_usermeta tables), and if you included –send-email, the new user will receive login credentials via email.
Best Practices for Ongoing User Management
Using the wp-cli create user command is just the first step. Maintaining a secure and organized WordPress site requires ongoing user management practices. However if you’re not careful, you run the risk of security issues because of poor login security. Here’s what we recommend that you do:
- Audit Accounts Monthly: Every month, review all active users and remove accounts that are no longer needed, such as former employees, completed client projects, or test accounts. Check for suspicious or unauthorized user registrations that might indicate security breaches. Verify that current user roles still match each person’s actual responsibilities, as job functions often change over time.
- Follow the Principle of Least Privilege: This means giving users only the minimum access level they need to perform their specific tasks. For example, authors should only be able to publish their own content without access to plugin management or site settings.
- Enforce Strong Passwords: Password security remains one of the most critical aspects of user management. Require all users to create complex passwords containing special characters, numbers, and mixed case letters. Implement password expiration policies that force users to update their credentials every 90-120 days.
- Rename Default Admin Username: The default “admin” username is a common target for brute force attacks because hackers know it exists on many WordPress sites. Change this default username to something unique and less predictable.
- Automatically Log Out Idle Users: Implementing automatic logout for idle users prevents unauthorized access when someone steps away from their computer without logging out. Set session timeouts for 15-30 minutes of inactivity, especially for users with elevated privileges like editors and administrators.
- Track User Actions Comprehensive user activity monitoring helps you identify both security threats and workflow issues. Log all user actions including login and logout times, failed login attempts, content changes, role modifications, and plugin installations. Use activity logging plugins like Blogvault to maintain detailed records.
Final Thoughts
the wp-cli create user command makes maintaining a WordPress site easy if you’re comfortable with using the commands. The wp cli create user functionality we’ve covered provides powerful, flexible options for adding team members, clients, and premium users with precise control over their roles and permissions.
However, if you’re looking for an easier tool that doesn’t require command-line expertise, BlogVault may be for you. It provides a user-friendly interface for WordPress management tasks, including user creation and site maintenance, making it accessible to administrators who prefer visual tools over command-line interfaces. The choice ultimately depends on your technical comfort level and the complexity of your user management needs.
FAQs
What are the WP user roles?
WordPress includes five default user roles with different permission levels. Super Admin has complete control over multisite networks, while Administrator manages individual sites with full access to settings, plugins, and users. Editor can publish and manage all posts and pages but cannot modify themes or plugins. Author can write, edit, and publish their own posts but cannot manage others’ content. Subscriber has the most limited access, only able to read content and manage their own profile. You can also create custom roles using plugins like User Role Editor for more specific permission sets.
How to create a new user in WP?
There are two main methods to create WordPress users. Through the dashboard, navigate to Users > Add New, fill in the required fields (username, email, password), select a role, and click Add New User. Alternatively, if user registration is enabled, visitors can register through your site’s registration page. For bulk creation or automation, the wp-cli create user command is faster.
How to create user using WP-CLI?
Use the command wp user create <username> <email> [options] from your WordPress directory. A basic example is wp user create johndoe john@example.com –role=editor –user_pass=”SecurePass123!”. You can add additional details like –first_name=”John” –last_name=”Doe” –display_name=”John Doe” –send-email to complete the profile and notify the user. The command requires SSH access to your server and WP-CLI installed on your system.
Where are user details stored?
WordPress stores user information in two database tables within your MySQL database. The wp_users table contains core user data including username, email address, encrypted password, and registration date. The wp_usermeta table stores additional user information such as first name, last name, user capabilities, preferences, and custom profile fields. When you create users through WP-CLI, the data gets inserted into these database tables, not stored in any file folders.
How to edit WP users?
You can edit users through the WordPress dashboard by going to Users > All Users, clicking on a username, and modifying the profile fields before clicking Update User. Using WP-CLI, update users with wp user update <username> –field=value, such as wp user update johndoe –user_pass=”NewPassword123!” –role=author –first_name=”Jonathan”. WP-CLI allows bulk editing and automation, making it ideal for managing multiple user accounts or scripting regular maintenance tasks like password resets.
Tags:
Share it:
You may also like
WordPress phpMyAdmin: Master The Ins And Outs
Managing your WordPress site will eventually lead you to its database. When that happens, you’ll likely face phpMyAdmin, and honestly, its interface can be intimidating. The unfamiliar terms and countless…
WordPress Enable Revisions: The Easiest Way for Non-Techies
WordPress revisions are meant to be your safety net. But what happens when you accidentally delete a crucial paragraph and discover that feature isn’t there to save you? It’s a…
LifterLMS Review: Is It Right For Your Courses?
Sorting through LMS plugins is overwhelming, and by now, LifterLMS has likely caught your eye as a possible solution. Well, you’re in the right place. This LifterLMS review is designed…
How do you update and backup your website?
Creating Backup and Updating website can be time consuming and error-prone. BlogVault will save you hours everyday while providing you complete peace of mind.
Updating Everything Manually?
But it’s too time consuming, complicated and stops you from achieving your full potential. You don’t want to put your business at risk with inefficient management.
Backup Your WordPress Site
Install the plugin on your website, let it sync and you’re done. Get automated, scheduled backups for your critical site data, and make sure your website never experiences downtime again.