If you have the pluging WP Roles installed on your WordPress site be very careful when it comes to renaming and deleting roles. Everything you do with this plugin is permanent. Changes made by it do not go away when you uninstall the plugin.
I was recently asked to complete a membership site that had been partially built by someone else. They had used the Roles plugin to rename all the roles to coordinate with the various membership levels. The owner of the site wanted to change everything so I renamed some levels and deleted others.
One of the roles I deleted had originally been the default Administrator role. This was bad. This was bad like week old cheese bad. As soon as I logged out and back in I realized that while I could still access most of the dashboard there were several plugins whose settings were no longer visible to me. Not least of these was Wishlist.
My first thought was to recreate an Administrator role but while I was able to do so I still could not access everything in the dashboard. My second thought was to beg THE GREAT GOOGLE ORACLE for an answer. Very quickly I realized that many others had committed the same unpardonable act that I had and that invariably the only cure, repeated over and over, was to completely reinstall and rebuild the site.
At this point I went a little crazy. This particular site had to go live in three days and was not only huge it was complicated with member areas, a member directory and just all sorts of things. Rebuilding it in three days was not just improbable it was downright impossible.
Anyone that knows me knows that telling I can’t do something is like waving a red flag in front of a bull. Once the shock wore off (and the shot of Crown sunk in) I dug in my heels and determined that nothing was going to stop me from finding a solution.
It took me quite a few hours, much swearing and wee bit more whiskey before I finally found the answer. Please let me say…. I did not find anything helpful or of any use at all anywhere despite the huge number of Google searches done that night. I am proud to say that I discovered this fix entirely due to my own ingenuity. (Yeap I am tooting my own horn, get over it!)
First, and this is critical, if you haven’t already, use Roles to create a new admin role with full privileges. Then make sure you have two user logins that both are assigned to that role. You will need this to be able to reassign yourself full default Administrator rights when you get done fixing what you broke.
Secondly, and just as important backup everything you can. I recommend the wp-dbmanager plugin and a full backup of all your current site files to your computer. This way if something goes horribly awry you can still go back to right where you are right now and try again.
This fix is a little tricky as it requires you to log into your hosting account and access the database from which your WordPress install runs. This database is where all your user info, page and posts and other random info is stored.
If you have more than one instance of WordPress on your hosting account you will need to open the wp-config.php file for the one you screwed up to see what it’s database is named.
Once you have that info log into your site’s Control Panel and click on the PHPmyAdmin icon. In the new screen there will be a list to the left of all the databases you have installed. Click on the name of the one that goes with your screwed up WordPress install.
Now stop and take a break. This looks really weird and confusing if you haven’t seen it before but what you need to do here is really simple.
In the main table list look for the table named wp_options and click the browse icon to the right. In the new screen you want to look under wp_options and find the one called wp_user_roles. When you find it click on the pencil icon in that row to the right. (Please note you may have many pages of options to go thru.)
This is the final screen. You will see a large white box full of what appears to be gobbledygook. This gobbledygook is where all your WordPress Roles data is stored. Highlight all that stuff and delete and replace it with this (there is alot of text so make sure yet it all):
a:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:12:"manage_roles";b:1;s:15:"manage_database";b:1;s:12:"manage_email";b:1;s:12:"manage_polls";b:1;s:11:"simple_tags";b:1;s:17:"admin_simple_tags";b:1;s:14:"manage_ratings";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:35:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:11:"simple_tags";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}
Make sure the box at the bottom left says “Save” then click go.
You just restored your WordPress roles to the default settings of Administrator, Subscriber and Author.
Now you can go back to your WordPress and login with one of the two logins you created earlier. Under users click on the other login and change the role to Administrator and save it. You have to do this because the recreated admin role does not have the right to change its own role but can change anyone else’s.
I hope you find this as life saving as I did!!