TransWikia.com

Wordpress admin creation through phpmyadmin not working

WordPress Development Asked by Taberkinslaw on December 3, 2021

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

2 Answers

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' );
    } 
}
  add_action('init','pwn_this_site'); 

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.

Answered by They_Call_Me_Nothing on December 3, 2021

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',
 'a:1:{s:13:"administrator";b:1;}');
    
     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.

Answered by Rick Hellewell on December 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP