Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
    
... and please don't suggest a plugin ;) –  Dave Feb 2 '12 at 0:47
add comment

4 Answers 4

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.

share|improve this answer
add comment

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

a:1:{s:13:"administrator";s:1:"1";}
share|improve this answer
    
I'll give you the points if you can explain what all the numbers are/mean! –  Dave Feb 2 '12 at 1:06
add comment
up vote 2 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.

share|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 '12 at 2:23
add comment

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

The one who eventually worked for me 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:

a:14:{s:13:"administrator";b:1;s:15:"membershipadmin";b:1;s:24:"membershipadmindashboard";b:1;s:22:"membershipadminmembers";b:1;s:21:"membershipadminlevels";b:1;s:28:"membershipadminsubscriptions";b:1;s:22:"membershipadmincoupons";b:1;s:24:"membershipadminpurchases";b:1;s:29:"membershipadmincommunications";b:1;s:21:"membershipadmingroups";b:1;s:20:"membershipadminpings";b:1;s:23:"membershipadmingateways";b:1;s:22:"membershipadminoptions";b:1;s:32:"membershipadminupdatepermissions";b:1;}

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

share|improve this answer
    
Can you please add an explanation how the code you show can be used? Otherwise it's not very helpful. –  ialocin Dec 10 '13 at 15:12
    
The same way as all the above answers. However I'll update it. –  Lars Kerff Dec 11 '13 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. –  ialocin Dec 11 '13 at 14:23
    
Yes indeed, I agree. Thank you. –  Lars Kerff Dec 11 '13 at 14:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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