“You do not have sufficient permissions to access this page.” on plugin admin page after update to Wordpress 3.0
Well, if you are having problem with your Wordpress plugins after an upgrade to Wordpress 3.0, this article might just help you. The error you will being seeing on your Wordpress plugins will most likely be located on the admin side of Wordpress. You will most likely see the message “You do not have sufficient permissions to access this page.” and starts debugging and looking for clues on what is happened suddenly with the new upgrade of Wordpress 3.0. (that what happens to me) You will most likely find yourself looking at the function user_can_access_admin_page() which return false and cause you debugging all these in the first place. Then, you will find yourself stuck at line 1407 of wp-admin/includes/plugins.php with the following code.
if ( isset( $plugin_page ) ) {
if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
return false;
$hookname = get_plugin_page_hookname($plugin_page, $parent);
if ( !isset($_registered_pages[$hookname]) )
return false;
}
Now, the culprit is definitely caused by $_registered_pages[$hookname] array variable not being set. Hence, this keep you wonder, “why there wasn’t any problem until now until Wordpress 3.0?”. How do we solve this?
Solutions for plugin “You do not have sufficient permissions to access this page.” error
There is an obvious solution for this that is to set the global array varaible of $hookname into it so that it always return a true.
GLOBAL $_registered_pages; $hookname = get_plugin_page_hookname( $plugin_file , '' ); $_registered_pages[$hookname] = true;
This way, you will bypass the validation easily. This is easy but who want hack when there is a properly way of doing it?
My problem solution
Well, my plugins problems can be solved this way but i believe there is an easier way out. Hence, after some try and reading i suspect there is a stricter rules implemented on Wordpress when creating your Wordpress plugin. Finally, i get a hold on what is wrong with my plugins that is causing “You do not have sufficient permissions to access this page.” on all my plugins admin page. Here’s the culprit.
#Before 3.0
$plugin_page = add_options_page("Hungred Feature Post List", "Hungred Feature Post List", 10, "Hungred Feature Post List", "hfpl_admin");
#After 3.0 onwards
$plugin_page = add_options_page("Hungred Feature Post List", "Hungred Feature Post List", 10, "Hungred-Feature-Post-List", "hfpl_admin");
Take note that the slug parameter is being changed from spaces to dashes. Wordpress get_plugin_page_hookname will remove all spaces on your slug parameter instead of leaving it which will give “Hungred Feature Post List” instead of “HungredFeaturePostList”. Since there is only “Hungred Feature Post List” exist within the $_registered_pages global array and “HungredFeaturePostList” wasn’t being registered. The validation fail and throw me an error page.
Related posts:
- How To Exclude Page Permanently In Wordpress Without Using Any Plugin here is a way to permanently exclude pages globally across...
- Remove Wordpress Admin Menu Without Affecting Wordpress Core System In here, we will discuss a few method that we...
- Get Wordpress Author Page Url With User ID This is a simple tutorial to inform others of a...
- Multiple Wordpress installation sharing one user table multiple Wordpress installation with the same user table? This means...
- Wordpress Plugin Development Tips And Tricks A list of useful tips and tricks for people who...










July 3rd
Worked like a charm! thanks for this article – I spent an hour chasing my tail before finding this. There seem to be several issues that will cause the “permissions” error message which makes diagnosing these problems a lot more difficult.
July 3rd
no problem rico
July 13th
Great. But where should I put your code? In functions.php or plugins.php?
July 13th
@Fabio: this code shouldn’t be placed anywhere. You should try to find add_options_page and ensure that the slug parameter does not have spaces for its name.
July 18th
You hack code where would I put that in the plugins.php. I want to bypass this as the slug I just can’t find for a couple of my plugins that don’t allow me access?
I just want to know where to put the hack now.
July 28th
I am absolutely dying here. I’ve been locked out of my own blog for weeks. I’m trying to try this fix (the 20th thing I’ve tried)…but wp-admin/includes/plugins.php only has 787 lines…and a grep for “_wp_submenu_nopriv” comes back with “not found”. SOMETHING is screwy here (WP 3.0)