Just trying to create a simple plugin with some Theme Options so I can practice. When I try to access the Theme Options page under Settings… I get the: You do not have sufficient permissions to access this page.
This is all I have in the plugin:
add_action( 'admin_menu', function(){
add_options_page( 'Theme Options', 'Theme Options', 'administrator', __FILE__, function(){
echo 'Hello';
});
});
Here are the parameters from the WordPress codex:
<?php
add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function);
?>
I am the admin. Tried creating another admin account, same result. Tried setting the slug parameter to a different slug, same result. I’m using WAMP on my local machine.
Any ideas? I came up short when trying to search for this issue when using WAMP on a local machine. Any help would be great.
administrator
isn’t a capability, it is a role, so the reason you get that error is because WordPress doesn’t recognizes the capability you gave.If you look up the capabilities of the administrator role, you can see that the administrator is the only one with the capability
manage_options
. This is the one you should use.So what you can do is change the capability to
manage_options
:Hope it helps!