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

I have a multisite installation running WP 3.5. My main site and a few other blogs on the network work fine. However, if I register a new user and site, that user gets the “You do not have sufficient permissions to access this page.” error any time they try to visit the admin panel of the site. The front end of the site works properly.

When I look at the user in the Network Admin interface, they are shown to be an admin of that site. If I add the Network Admin to the site, I can view the admin area.

Read More

I’ve tried the usual suggestions of disabling and removing all plugins, activating the Twenty Twelve theme and reinstalling the WP core. None of these work. How can I fix this?

Related posts

Leave a Reply

5 comments

  1. I spent several hours of my Saturday looking for this error. I could not find a guide anywhere on the ‘net that described my eventual solution. Here is my solution.

    In the WP core, the “You do not have sufficient permissions to access this page.” error is generated at the end of /wp-admin/includes/menu.php. A grep of my plugin directories also showed that several plugins also could generate this error.

    Make a backup of menu.php, and replace the code inside the if block on lines 224-227 (as of v3.5) with the following:

    if ( !user_can_access_admin_page() ) {
       $a = array(
           'Pages No Access' => $_wp_menu_nopriv,
           'User Info' => $current_user,
           'Roles' => $wp_roles->get_names(),
       );
       $s = sprintf("n<br /><pre>%s</pre>", print_r($a, true));
       do_action('admin_page_access_denied');
       wp_die( __('You do not have sufficient permissions to access this page.'.$s) );
    }
    

    DON’T Leave this code live on your site unless you are actively debugging! Replace this with the backup menu.php if you need to step away for a while.

    Try to access the admin side again. This error page will tell you a few things:

    1. If you get additional output on your failure page, this tells you that the failure is being generated by the WP core. In my case it was. If you don’t get additional output, you know you need to start looking for the plugin that is causing the error.
    2. Any page in the Pages No Access array set to 1 is not accessible to the user. In my case, all pages were set to 1.
    3. In User Info, check to see if the user has the correct roles and capabilities. In my case, the user had a role of 10 and the capabilities they should have as an admin.
    4. In Roles you will see a list of defined roles for the site. In my case, I had no defined roles. Here was my problem.

    In my case, I was able to browse my database in phpMyAdmin, and look for the [WPDB_PREFIX]_[SITENO]_user_roles entry in the [WPDB_PREFIX]_[SITENO]_options table. I had changed my WPDB_PREFIX, but some plugin had created a custom user role and written this with the default wp_ prefix. I was able to copy over the entry from a working site into the non-working site. As soon as I did the admin was immediately able to access the site.

    My install was further complicated because I was using the new blog templates plugin, and my template site also had it’s database corrupted in the same way.

    I hope this helps.

  2. As I was migrating from a multisite install, the problem was due to the fact that roles are named based on table names. So I solved my problem when I named option wp_7_user_roles to wp_user_roles.

  3. After going through a few solutions including capabilities -nothing seemed to work. I finally rechecked the size of live wp_usermeta verses localhost wp_usermeta and found that the upload had been chopped and missing some values. I emptied the table and re-uploaded the whole usermeta afresh. WordPress worked straightaway after the upload. – Hope this saves someone time.

  4. I had issues with this as well.

    What I wanted was to give one user Admin but remove certain menus from the backend admin side bar.

    I removed AAM because it was giving permission problems and used Menu Editor Pro instead. Everything works perfectly.

    Of course, this is not the most secure way to go about it, it still allows access to the hidden admin pages my manually typing in the urls, but my client wouldn’t know how to get there anyway so this works.

  5. The permission problem relates to the following tables.

    Table [prefix]_usermeta

    The rows with the column meta_key should reflect the prefix as follows.

    [prefix]_capabilities
    [prefix]_user_level
    

    Table [prefix]_options

    The single row with the column option_name should reflect the prefix as follows.

    [prefix]_user_roles