How to change WordPress user roles in MySQL database using PhpMyAdmin?

We will be editing the database rows using PhpMyAdmin tool given with cPanel by many hosting companies

You can change the WordPress user roles by following the given steps:

Step 1: Open phpMyAdmin on cPanel.

Step 2: Open the wp_usermeta or xxx_usermeta table in the database as highlighted. (wp_ is just prefix, your table prefix may be different)

wordpress tables in database

Step 3: In wp_usermeta table, you can find wp_capabilities under meta_key column.

User Roles in usermeta table

Step 4: The roles are saved in form of serialized PHP array. Change the user role you want to assign to the current user by changing the meta_value as:

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;}

Posted

in

,

by

Tags:

Comments

14 responses to “How to change WordPress user roles in MySQL database using PhpMyAdmin?”

  1. Quin Avatar
    Quin

    This is perfect!
    I was mucking around with a local dev site and just emptied the usermeta table without giving much thought, but I was able to add the admin capabilities because of this. Thanks 🙂

  2. Dr Sadaqat Avatar
    Dr Sadaqat

    really helpful

  3. GBee Avatar
    GBee

    Thank you, this was helpful. I’ve noted that installing W3SuperCache somehow changed my user permissions.

  4. GBee Avatar
    GBee

    I’ve just noted that this works for a single installation and doesn’t work for a multisite. Any workaround for that?

    1. Harshvardhan Malpani Avatar

      Reason for that is because in multisite, user level and capabilities are stored as “wp_2_user_level” and “wp_2_capabilities” meta_keys where 2 is site id
      Read more at https://codex.wordpress.org/Database_Description#Table:_wp_sitemeta

  5. Piggins Avatar
    Piggins

    I managed to remove my permissions to update wordpress site when I was in wishlistmember dashboard. I’ve tried updating in MYPHPadmin but there is no privileges option – help!

  6. Samuel Avatar

    Dude, You just saved my life man!

  7. […] سلام احتمال داره که نقش های سایت شما به هم ریخته باشه که این اصلا طبیعی نیست و خوب هم نیست. از تیبل users اول آی دی یوزر تون رو پیدا کنید و بعد طبق لینک زیر یوزر خودتون رو چک کنید اگر ادمین نبود نقش ادمین بهش بدید: How to change WordPress user roles in MySQL database using PhpMyAdmin? | Tutes Club […]

  8. […] How to change WordPress user roles in MySQL database using PhpMyAdmin? How to Redirect Users after Login in WordPress […]

  9. Bassam Avatar
    Bassam

    what the rolls code for supper admin (for multisite)

  10. David Avatar
    David

    What about for super administrator that manages a network?

  11. Zee Avatar
    Zee

    Hi there, Im also faced with an issue where I cannot access anything in wordpress dashboard as a main user. I tried the above but no luck. Can’t edit site, neither access plugins, themes, woocommerce, etc.
    any advice please?

Leave a Reply

Your email address will not be published. Required fields are marked *