WordPress, “You do not have sufficient permissions to access this page”


WordPress upgrades is a task most users do on a frequent basis,and most of the time it works flawlessly. But once in a while something goes wrong and WordPress doesn’t behave the way we expect. The most common complaint I see is the following error being thrown during wp-admin login after a WordPress database upgrade.

“You do not have sufficient permissions to access this page”

This innocuous message however is the source of many a wasted hours. Although there could be many reasons for the above message, the one I most often see cited is the inconsistency between WordPress prefix for the following values:

Table – Column – Value
wp_options – option_name – wp_user_roles
wp_usermeta – meta_key – wp_capabilities
wp_usermeta – meta_key – wp_user_level

So if you have a value like ‘wpress_capabilities’ and the other ‘wp_user_roles’ (notice the different prefixes), the error is thrown. In many cases the value itself is missing from the table after a database upgrade. In a recent case, after a WordPress database upgrade the wp_user_roles option name was missing from the ‘wp_options’ table, which disallowed admin login and displayed the above message. The solution was to add the option name manually to the table with the option value taken from a old database backup. If you do not have a database backup (God forbid) you can use the value from a fresh WordPress installation.

To quickly check if all the above values exist with also the same prefix, you can use the following simple query.

SELECT option_name AS A FROM wp_options WHERE option_name LIKE '%_user_roles'
UNION 
SELECT meta_key AS A FROM wp_usermeta WHERE meta_key LIKE '%_capabilities'
UNION
SELECT meta_key AS A FROM wp_usermeta WHERE meta_key LIKE '%_user_level'

Which will return:

A
wp_user_roles
wp_capabilities
wp_user_level

This site is a digital habitat of Sameer Borate, a freelance web developer working in PHP, MySQL and WordPress. I also provide web scraping services, website design and development and integration of various Open Source API's. Contact me at metapix[at]gmail.com for any new project requirements and price quotes.

1 Response

1

Cubicle Ninjas

February 26th, 2013 at 8:59 am

Thanks for calling this out Sameer! Good post.

Your thoughts