We help IT Professionals succeed at work.

Wordpress - create new admin user via phpmyadmin

Trevor Local
Trevor Local asked
on
Hi

Two parts:

How can I tell which WP user is an administrator via phpmyadmin?

I need to create a new admin user via phpmyadmin. The few sites I found that list the steps and the query seem to have problems with the code (as I read the comments on those pages). And I've not done a query before.

I've taken a backup of the database, and this site is on WordPress 3.8.5

thx
Comment
Watch Question

Don't talk to me.
Commented:
How can I tell which WP user is an administrator via phpmyadmin?

Look in the wp_usermeta table for the wp_capabilities key (if you are using a custom prefix for tables, the key will also have that prefix) with the following value:

a:1:{s:13:"administrator";b:1;}

Get the user_id from that row, look up that user in wp_users.  That's your administrator.

I need to create a new admin user via phpmyadmin. The few sites I found that list the steps and the query seem to have problems with the code (as I read the comments on those pages). And I've not done a query before.

It's not that complex and can be done from the phpMyAdmin interface.

1) Create a new user account by inserting a new row in wp_users.  Leave the password blank (you'll just be resetting it anyway) but make sure you add a working email address.  After insert, get the WP ID number assigned.

2) Insert two new rows into wp_usermeta.  One takes the key wp_capabilities and has the value I pasted above.  The second row has the key wp_user_level and a value of 10.  Make sure you add the user ID from step 1 when inserting both rows.

3) Now reset the password from the WordPress login like you normally would.  Once you reset the password, you'll be able to login with admin privileges.

Alternately, if you are hijacking the site from an admin who isn't around any longer just locate that user as I described above and change the email on the account to yours.  Then reset the password and login.

Author

Commented:
thanks for the explanation. I found the admin user, but I will still create my own as well.

I inserted the new row in wp_users, now trying to insert rows into wp_usermeta. I don't see an option or where to insert  the wp_capabilities key or wp_user_level.
Jason C. LevineDon't talk to me.

Commented:
If you are using PHPmyadmin then you are inserting into the user ID, key, and value columns. Wp_capabilities is the actual text you are inserting.

The user ID is the user ID.  The key is wp_capabilities, the value is that string from my original post.

Then repeat with user ID, wp_user_level, and 10

Author

Commented:
That was it....thanks again. Worked like a charm.

Author

Commented:
thanks!