Here are five different methods to create a new WordPress Admin user.
In all of the examples below I will use the following username/password combination, so make sure to change it before running any of the commands:
username123 | change username123 with your username |
password123 | change password123 with your password |
[email protected] | change [email protected] with your email address, or give me admin if you want.. 😅 |
1. Create a WordPress Admin user from WP Dashboard
Log into your WordPress Admin account and in the menu bar on the left side of your dashboard, select the Users > Add New option.

Fill out the relevant information and assign the user the role of “Administrator“.

When you’re finished, click “Add New User“
2. Create a WordPress Admin user using PHP
From your File Manager or FTP locate the file ../wp-content/themes/YOUR-THEME-NAME/functions.php
Download the file to your PC, open it in a text editor and add the following code:
<?php function wpb_admin_account(){ <?php function wpxss_admin_account() { $user = 'username123'; $pass = 'password123'; $email = '[email protected]'; if (!username_exists($user) && !email_exists($email)) { $user_id = wp_create_user($user, $pass, $email$user = new WP_User($user_id); $user->set_role('administrator'); } } add_action('init', 'wpxss_admin_account'); ?>
Then save it and upload it back to the server, replacing the old functions.php file.
3. Create a WordPress Admin user using SQL
The following SQL command will create a new admin user:
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `user_registered`)
VALUES ('username123', MD5('password123'), 'firstname lastname', '[email protected]', '0', NOW());
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wpxm_user_level', '10');
NOTE: Change wp_ with your table prefix.
Simply login to PHPMyAdmin, select the database, and run the query.
4. Create a WordPress Admin user programmatically
Add the following code in your theme’s functions.php file to add programmatically the user with the $username, $password, and $email as the Administrator.
/*
* Create an admin user from functions.php
* wpxss.com
*/
add_action('init', 'wpxss_my_custom_add_user');
function wpxss_my_custom_add_user() {
//change username123 with your username
$username = 'username123';
//change password123 with your password
$password = 'pasword123';
//change [email protected] with your email address
$email = '[email protected]';
if (username_exists($username) == null && email_exists($email) == false) {
$user_id = wp_create_user($username, $password, $email);
$user = get_user_by('id', $user_id);
$user->remove_role('subscriber');
$user->add_role('administrator');
}
}
5. Create a WordPress Admin user from WP-CLI
If you have WPCLI enabled on your hosting account then simply enter the WP directory and run this command:
wp user create username123 [email protected] --role=administrator --user_pass=password123
