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!

link|improve this question

75% accept rate
... and please don't suggest a plugin ;) – Dave Feb 2 at 0:47
feedback

3 Answers

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

a:1:{s:13:"administrator";s:1:"1";}
link|improve this answer
I'll give you the points if you can explain what all the numbers are/mean! – Dave Feb 2 at 1:06
feedback
up vote 1 down vote accepted

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:

a:3:{s:15:"membershipadmin";s:1:"1";s:10:"M_add_ping";s:1:"1";s:10:"subscriber";s:1:"1";}

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

a:4:{s:13:"administrator";s:1:"1";s:15:"membershipadmin";s:1:"1";s:11:"M_add_level";s:1:"1";s:10:"M_add_ping";s:1:"1";}

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.

link|improve this answer
1  
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. – m0r7if3r Feb 2 at 2:23
feedback

The string below actually represents an array in serialized form.

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

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

Array 
{
     "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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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