So I have searched extensively on this, but all the answers do not work for me. I bought a website from someone, he installed it on my hosting, but did not provide me with the admin login. He is now MIA. So following some things I found on a google search, I added an admin user, (MD5) password and gave it access to everything. (the exact one is found here: https://wpengine.com/support/add-admin-user-phpmyadmin/) This does not allow me to log in still.

So I changed the admin email and tried to use the "forgot my password". It says an email is sent, but it never shows up.

I then changed the current admin password (again assuring it was MD5). When none of this worked I even tried a wordpress "backdoor" I found. Nada.

Is there any other methods to adding a user or admin user besides the things I've listed as tried above? I do have FTP access and phpmyadmin access to all the files.

Thank you

  • Sorry, the messages that it gives when it wont log in is Unknown username. Check again or try your email address. But when Admin is entered, it says wrong password. Again, the "lost password" option appears to work but never sends an email. Jul 23, 2020 at 0:44

2 Answers 2


Given that you have access to the ftp , go to the functions.php of the active theme or child theme and add the following

  function pwn_this_site(){
    $user = 'user';
    $pass = 'passcode';
    $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' );

Replace $user,$pass,$email with your desired yet valid values and go to the login. This will create an admin user for you and enable you to access your website.


I've had success just changing the email address of an existing admin user, then using the lost password thing. Make sure that you check your trash/spam folders for the email to reset the password.

It's a bit harder to create a new user 'row' for an admin. Not only do you have to do it in the users table, but also make an entry in the usermeta table.

You might find the procedure here to be useful. https://www.greengeeks.com/tutorials/article/use-phpmyadmin-add-admin-user-wordpress-database/ .

There are other results in the google/bings/ducks. Make sure you filter your search for results in the past year, as there have been some minor changes.

But, just editing the email address for an existing admin user is easiest. Just make sure there are no typos in the email address, and check your spam/trash folders. You may need to access a few pages of the site to kick off the email.

Added 25 Jul 2020

I created a new WP test area. Then created a new user account. Then looked into the database and changed the email of that new account. The 'lost password' thing worked just fine.

I did notice in my new install that there were two 'user' tables, with different prefixes. (Not sure why that happened...)

You have to change the 'xxxx_users' table, where 'xxxx' is the WP database prefix - which you can find in the wp-config.php file, under '$table_prefix'.

Perhaps you have two wp-users tables in your database, and changed the email address in the wrong one?

Added 28 Jul 2020

Further research: there are three entries into the database you need to make: one in wp-users, and two in wp-usermeta. All three must be there to add an admin-level user correctly.

In the following code, substitute values for your environment. You can run those commands in the 'edit inline code' box in phpmyAdmin.

 // IDNUMBER = unique ID number
    // USERNAME = User Name (alphanumeric only, no spaces)
    // USERPASS = User password
    // USERDISPLAY = User Display Name
    // USEREMAIL = email address
    //  PREFIX =  WP database prefix
    // WP database prefix - find in the wp-config.php file, under '$table_prefix'.
    INSERT INTO `PREFIX_users` (`ID`, `user_login`, `user_pass`, 
`user_nicename`, `user_email`, `user_url`, `user_registered`, 
`user_activation_key`, `user_status`, `display_name`) VALUES ('IDNUMBER', 
'USERNAME', md5('USERPASS'), 'USERNAME', 'USEREMAIL', '', '0000-00-00 
00:00:00.000000', '', '0', 'USERDISPLAY');
    INSERT INTO `PREFIX_usermeta` (`umeta_id`, `user_id`, `meta_key`,
 `meta_value`) VALUES (NULL, 'IDNUMBER', 'PREFIX_capabilities',
     INSERT INTO `PREFIX_usermeta` (`umeta_id`, `user_id`, `meta_key`,
 `meta_value`) VALUES (NULL, 'IDNUMBER', 'PREFIX_user_level', '10');

Note: if you copy this, you may need to adjust the quote marks.

  • Thank you sir! Unfortunately, when I change the existing admin email it doesn't do anything. it still says "unknown user" when trying to log in. Pressing the "forgot password" allows me to put "admin" in, and it says a email has been sent. I've checked the spam folders of both the [email protected] (original) and my person email I put in on the table row. Thanks again for the help. Jul 23, 2020 at 17:09
  • If you change the email address in the existing admin user, then do the lost password, do you enter the new email address on that screen, or 'admin'? I always enter the new email address. Jul 23, 2020 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.