Recently I had an Issue where I was kicked out of my WordPress Administrator page wp-admin and found that my user record had been deleted.
Regardless of why this had happened, I needed to manually create a new user with Admin rights to edit my wordpress site.
The website WPBeginner has a really good tutorial, although as I was to find out there is some missing information, which I have corrected in this post. See the full article here.
The objective is to insert data into the tables wp_users and wp_usermeta.
From your host providers C Panel, select PHPMyAdmin and then select the correct prefix for the tables linked to your website.
phpMyAdmin wp_users table
– We need to insert our new admin user’s information; Select the “Insert” tab.
– Add the following into the Insert form:
ID – pick a number (in our example, we will use the number 4).
user_login – insert the username you want to use to access the WordPress Dashboard.
user_pass – add a password for this username. Make sure to select MD5 in the functions menu (Refer to the screenshot below).
user_nicename – put a nickname or something else that you would like to refer yourself as.
user_email – add the email you want to associate with this account.
user_url – this would be the url to your website.
user_registered – select the date/time for when this user is registered.
user_status – set this to 0.
display_name – put the name you like to display for this user on the site (it can be your user_nicename value as well).
Click on the Go Button
Step 2
– Add two rows to the wp_usermeta table. NOTE: Replace “wp_” with the appropriate prefix for your wordpress database tables
– Select the “Insert” tab.
– Add the following into the Insert form:
unmeta_id – leave this blank (it will be auto-generated)
user_id – this will be the id of the user you created in the previous step. (Remember we picked 4).
meta_key – this should be wp_capabilities
meta_value – insert this: a:1:{s:13:”administrator”;s:1:”1″;}
Insert another row with the following information:
unmeta_id – leave this blank (it will be auto-generated)
user_id – this will be the id of the user you created in the previous step. Remember we picked 4.
meta_key – this should be wp_user_level NOTE: Replace “wp_” with the appropriate prefix for your wordpress database tables
meta_value – 10
Click on the Go button.
Initially I had created a user Id with wp_capabilities in the meta key for the first insert of _USERMETA table and wp_user level in second nsert of _USERMETA table. The result was that I could log in but not access any of the functionality inside the wordpress admin area. What I should have done was replaced wp_ with the appropriate wordpress instalation prefix.
Once I had done that I had full admin rights to the WP-Admin area and was able to continue developing the site.
Hope this helps if you’re in a similar situation.
John