WP Error – You do not have sufficient permissions to access this page

This is a WordPress error where all you see is a message saying You do not have sufficient permissions to access this page I have resolved this problem.

It stems from the WordPress database prefix that you use. If it is wp_ which is the default, then I don’t think you will ever see this error. But maybe you changed it to improve security of your blog, but ironically, you were denied access too?

Or possibly a plugin made this kind of change, and after a WordPress update, the changes broke your blog?

Another reason to change the database prefix is where you are sharing the same core code between multiple blogs on the same host such as with subdomain blogs.

The You do not have sufficient permissions to access this page error is displayed when you try and login, and at the end of the file: wp-admin/menu.php it detects that you don’t have sufficient access rights, displays the message, and halts execution of the script.

The actual point where the check is made is in the file: wp-admin/includes/plugin.php in the function user_can_access_admin_page() This has a line of code like this:
if ( isset( $_wp_menu_nopriv[$pagenow] ) )
return false;
That decides that you don’t have the required privilege to access the page that you are on now.

The cure seems to be to replace the wp_ in the wp_usermeta database table for the meta_key entries, specifically wp_capabilities and wp_user_level i.e. rename these, replacing wp_ with your database table prefix. And, in the wp_options database table do a similar change to the option_name of wp_user_roles. And in your wp-config.php file, there needs to be a line of code as follows: $table_prefix = ‘wp_’; This sets the prefix.

Finally, make sure that the correct URLs for your site are in the wp_options database table under the option values for siteurl and home.

You can use PHP My Admin in your cPanel to do this stuff.

Hopefully, in future releases of WP, this dependency of database meta_key names on the table prefix will be removed.

Good luck

Leave a Reply

Your email address will not be published. Required fields are marked *