• Resolved olddocks

    (@olddocks)


    I am struggling with a strange issue in my theme options page. I am trying to add a menu page under appearance for theme settings…

    add_theme_page( 'Theme Option','softlights Options', 'edit_theme_options', 'theme_options.php', 'softlights_options_page');

    As you can see, if i change the menu slug “theme_options.php” to “soft lights-theme-options”, the the theme settings page crashes throwing this error

    You do not have sufficient permissions to access this page.

    What is causing the issue? How do i fix it?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Is it just a typo? “soft lights-theme-options”? This slug is going to be a URL parameter and therfore cannot contain spaces (or a bunch of other characters) without the proper URL encoding. Try “softlights-theme-options” instead.

    Thread Starter olddocks

    (@olddocks)

    chris- the3rd parameter is the slug, not the second one, which is title.

    Moderator bcworkz

    (@bcworkz)

    Chris IS referring to the slug, in your words:

    if i change the menu slug “theme_options.php” to “soft lights-theme-options”

    You have a space between “soft” and “lights” that probably should not be there.

    From what hook are you calling this function? It should be ‘admin_menu’.

    Thread Starter olddocks

    (@olddocks)

    oh thanks! i am sorry yes it was a typo. i changed it to softlights-theme-options without spaces, still the problem persists.

    In the wordpress codex http://codex.wordpress.org/Function_Reference/add_theme_page

    it says

    NOTE: If you’re running into the »You do not have sufficient permissions to access this page.« message in a wp_die() screen, then you’ve hooked too early. The hook you should use is admin_menu.

    I dont want to hook into ‘admin_menu’ as the wordpress theme reviewers insist that themes must use edit_theme_options hook to get approved.

    what does this mean?

    edit_theme_options is not a hook but a user capability. The admin_menu hook registers a function where you then can register the theme page. Using the proper hook has nothing to do with setting the user capability to edit_theme_options. Have you tried something like this?

    add_action( 'admin_menu', 'my_plugin_menu' );
    
    function my_plugin_menu() {
    
      add_theme_page( 'Theme Option', 'softlights Options', 'edit_theme_options', 'softlights-theme-options', 'my_plugin_function' );
    
    }
    
    function my_plugin_function() {
    
      echo "<p>Hello World!</p>";
    
    }
    Thread Starter olddocks

    (@olddocks)

    Thanks chris, fixed the issue. It seems that accessing old page not in the menu-slug causing this issue. it works

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Strange issue with theme options page?’ is closed to new replies.