So yeah, I'm a genius. I managed delete all my admin capabilities (thank you very much Membership plugin). I could restore them, ...if I had admin access, lol.

Anywhoo, how can I give all my capabilities back to admin? I have access to the database via PHPMyAdmin but have no idea where or what to add back to the DB.

Any help would be appreciated. Thanks!

  • ... and please don't suggest a plugin ;)
    – Dave
    Commented Feb 2, 2012 at 0:47

6 Answers 6


The string below actually represents an array in serialized form.


a:1 means an array with a single element
s:13 means string and the length of the string followed by

     "administrator" => "1"

Once that is in the table, you can use the unserialize() function to return it to an array for use in your code.

Many thanks.


It's the wp_capabilities in the usermeta table. Mine says:

  • I'll give you the points if you can explain what all the numbers are/mean!
    – Dave
    Commented Feb 2, 2012 at 1:06
  • 2
    a = array, s = string. The number is the size of the element. It is standard PHP serialization. a:1 = next element is a single element array, s:13 = next element is a 13 character string, s:1 = next element is a single character string
    – NiloVelez
    Commented Oct 27, 2016 at 8:43
  • I've faced the same issue and it worked for me. But here's a more challenging question: how come that happen? The only plugin I use is JWT for authentication and a custom Template for api stuff. I'm not changing any permission or even adding a unknow plugin/template to my site. I'm wondering why that happened. Commented Jul 13, 2020 at 17:17
  • I actually accessed my panel and here's something that maybe is the reason why: WordPress has detected that your site is running on an insecure version of PHP. Commented Jul 13, 2020 at 17:18

Ok, sorry for asking. I figured it out. But for future people, here's a suggestion.

Step 1 (BACKUP!!!!) - backup your database, if the next step screws you over and you don't have a backup it's your own fault.

Step 2 - Use PHPMyAdmin or similar tool to access your DB, find the wp_usermeta table and then sort by user_id. User #1 is your admin. Next find your wp_capabilities field and click edit (this is the part that got screwed up).

I replaced what I had that was screwed up. This:


with this (which I copied from another WP database):


Before I check my own answer, can anyone confirm my answer, or explain the contents of this field and how it should properly be listed? You may take my answer and rewrite it as your own, and if it's proper I'll check your answer.

  • 3
    It will not always be user_id 1 (though generally it will). You should go to the users table, find the username you want to be an admin, note the user_id, then use the method listed above, but for that user_id.
    – mor7ifer
    Commented Feb 2, 2012 at 2:23

I made the database changes as instructed but when I signed in as an administrator I still could'nt alter users or pages.

When comparing the database field for user roles I noticed it was different from other Wordpress installations. My solution was this:

Find the field named "wp_user_roles" in the table named [database prefix]_options, e.g. "wp_options", and make sure it has all capabilities for administrators. It's a serialized string with a lot of information so I think the easiest thing to do is to copy the data from a clean Wordpress install.


This is pretty simple. All I did was open phpmyaddmin, I selected a database from my former website I created, searched for wp_usermeta, clicked on user_capabilities, and since admin id is 1, all I did was copy the strings


and pasted it in my problematic db. Clicked save, log out the log back in and I got my roles back


I had the same problem and all these solutions didn't help me.

The one which eventually worked for, was:

  1. Log in to your PHP Admin to edit the database
  2. Find the table wp_usermeta and see what the ID is of the admin (probably 1)
  3. Now find the wp_capabilities field
  4. Replace the line with the following line:


Update and now you have permission to everything in the membership plugin.

  • Can you please add an explanation how the code you show can be used? Otherwise it's not very helpful. Commented Dec 10, 2013 at 15:12
  • The same way as all the above answers. However I'll update it.
    – Trekdrop
    Commented Dec 11, 2013 at 14:07
  • I couldn't see those on the review queue and it's actually best anyway if your answer is valid on itself. Like it is now, after your update. Commented Dec 11, 2013 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.