Group Admins

WordPress Troubleshooting and Support

Public Group active 1 year, 5 months ago ago

WordPress support from our community

New Admin Options Page trouble

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1585
    Chad
    Participant

    Hello,

    I having a problem adding a options page for my plugin under the setting tab but when i try to access that page I get the error

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

    After searching online I found multiple threads with the same problem but nothing seem to work.

    Below is the plugin code

    Code:
    add_action(‘admin_menu’, ‘ChapterDisplay_admin_actions’);

    function ChapterDisplay_admin_actions()
    {
    add_options_page("Chapter Display", "Chapter Display", "manage_options", "Chapter Display", "ChapterDisplay_Admin");
    }

    function ChapterDisplay_Admin()
    {
    if ( !current_user_can( ‘manage_options’ ) )
    {
    wp_die( __( ‘NO ACCESS.’ ) );
    }

    include(‘ChapterDisplayAdmin.php’);
    }

    When we click on the “Chapter Display” link in the settings menu – get the above error shows.

    Thanks
    Chad

    #2770
    amylaneio
    Spectator

    Hi Chad. On the fourth line of the code there are a lot of “"”s. Are these in the original code, or did they just get messed up when you pasted the code?

    #2771
    Chad
    Participant

    Andy,
    I was using double quotes … I did change them to single and still getting that error. Thanks for catching that

    Code:
    add_action(‘admin_menu’, ‘ChapterDisplay_admin_actions’);

    function ChapterDisplay_admin_actions()
    {
    add_options_page(‘Chapter Display’, ‘Chapter Display’, ‘manage_options’, ‘Chapter Display’, ‘ChapterDisplay_Admin’);
    }

    function ChapterDisplay_Admin()
    {
    if ( !current_user_can( ‘manage_options’ ) )
    {
    wp_die( __( ‘NO ACCESS.’ ) );
    }

    include(‘ChapterDisplayAdmin.php’);
    }

    It’s not even getting to my wp_die function. It still displays “You do not have sufficient permissions to access this page.”

    #2772
    Steve
    Keymaster

    @Chad–

    The 4th parameter in add_options_page needs to be a slug. You currently have it as a phrase. Try replacing with this:

    add_options_page('Chapter Display', 'Chapter Display', 'manage_options', 'chapter-display.php', 'ChapterDisplay_Admin');

    Also, since you have already set the capability for this page to manage_options when you registered it with add_options_page, you don’t need your wp_die statement.

    #2773
    Chad
    Participant

    @Steve

    That was it.. Thanks

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.