5 Easy ways to Create a WordPress Admin user

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:

username123change username123 with your username
password123change password123 with your password
[email protected]change [email protected] with your email address, or give me admin if you want.. 😅

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

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:

 function wpb_admin_account(){
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);
add_action('init', 'wpxss_admin_account');

Then save it and upload it back to the server, replacing the old functions.php file.

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.

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);

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

Was this post helpful?

Leave a Comment