Update User Role in WordPress for User via Back-end Database

Mindwatering Incorporated

Author: Tripp W Black

Created: 08/03 at 03:05 PM

 

Category:
Linux
Other

Task


Scenario:
The lone administrator of WordPress web site has left the company. We need to make an existing user (e.g. an editor named Tom) the new administrator within WordPress.

Overview:
These instructions will take an existing user who has some level of access (e.g. Contributor or Editor) and update his/her WordPress access to have the Administrator role by directly updating the database table.

Notes:
- This example will use phpMyAdmin.
- We update the wp_abcd9z_usermeta table. In old versions of WordPress, the table was/is just wp_usermeta.
- We will update both the wp_abcd9z_capabilities and ddd fields/meta_keys.
- Confirm you have a back-up of this application before starting. These are fairly low risk edits, but always have a back-up.

Example:
Nickname: Tom Testor
First Name: Tom
Last Name: Testor


Steps:
1. Open database in phpMyAdmin
a. Login:
web browser --> phpMyAdmin login --> Enter username and password

b. Navigate to the table, wp_abcd9z_usermeta, where your prefix to usermeta will be different.


2. Determine the user_id of the person (e.g. Tom Testor):
- If the number of the people is not very long:
- - Scroll through the pages (table rows) looking under the meta_key column until you see the new administrator's name in the nickname, first_name, or last_name records. Note the number in the user_id column for that/those records. (e.g. 77)

- Instead for a large table of users metadata, you can update the SELECT statement and using one of the name fields:
- - Edit (near the top, which will switch to the SQL tab) --> SELECT * FROM `wp_abcd9z_usermeta` WHERE `last_name`=`Testor`--> click Go (button)

--> In this example, the filter displays records showing that Tom Testor has user_id of 77


3. Locate and update the access roles record for Tom Testor/user_id 77:
a. Filter the SELECT to show only the new administrator's rows:
Edit (near the top, which will switch to the SQL tab) --> SELECT * FROM `wp_abcd9z_usermeta` WHERE `user_id`=77 ORDER BY `user_id` ASC;

b. Locate the meta_key named wp_abcd9z_capabilities and click Edit/pencil icon to edit this record on the Insert tab.

c. On the insert tab, replace the meta_value field/column for this record to the administrator role string: a:1:{s:13:"administrator";b:1;} --> click Go (button)

b. Locate the meta_key named wp_abcd9z_user_level and click Edit/pencil icon to edit this record on the Insert tab.

e. On the insert tab, replace the meta_value field/column for this record to the all-powerful (WordPress) administrator role level: 10 --> click Go (button)


4. Have user retest with their WordPress login. (If already logged in, they can simply reload the web page already being viewed.)



---

WordPress Roles:
Subscriber
a:1:{s:10:"subscriber";b:1;}

Contributor
a:1:{s:11:"contributor";b:1;}

Author
a:1:{s:6:"author";b:1;}

Editor
a:1:{s:6:"editor";b:1;}

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



previous page

×