Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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:

add_options_page( __( 'Theme Options' ), __( 'Theme Options' ), 'manage_options', __FILE__, function() {
    echo 'Hello';
} );

Hope it helps!

share|improve this answer
    
manage_options also didn't work. I believe it has something to do with setting FILE as the slug. When I change it to js_options.php ... it works. I'm still curious as to why FILE wouldn't work though? –  Josh Dec 18 '12 at 14:47
    
I think because the menu-slug has to be unique, when you use __FILE__, it never will be an unique filename, because it already exists. –  Mike Madern Dec 18 '12 at 15:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.