• David Gard

    (@duck_boy)


    Hey all,

    I’m trying to register an admin page, but I don’t want it to appear in any menus. Is there a function (or a way of manipulating one of the existing add_xxx_page() functions) to do this?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    (@esmi)

    I’ve not tried it but what about initially adding the page item as per usual and then hiding it in the menu using CSS?

    Thread Starter David Gard

    (@duck_boy)

    Nevermind, as is oftern the way, I stumbled across the answer as soon as I stopped looking!

    Thanks for the suggestion though Esmi.

    $this->pagehook = add_submenu_page(
        'options.php',
        __('Edit Chart'),
        __('Edit Chart'),
        'edit_charts',
        'edit-single-chart',
        array(&$this, 'on_show_page')
    );

    Explained in the second example in the codex for add_submenu_page().

    Thread Starter David Gard

    (@duck_boy)

    Ok, so the above code does through up an error –

    When checking user_can_access_admin_page(), because options.php is not a key in the global $admin_page_hooks, the page type is set wrongly as admin, not settings. This causes WP to tell me that I do not have permission to edit the page, when I clearly do.

    I’d ideally not like to go down the CSS route, but I will look in to that for now.

    If anyone has any other suggestions, I’d be greatful.

    Thanks.

    Hey duck__boy,
    The solution at https://stackoverflow.com/questions/3902760/how-do-you-add-a-wordpress-admin-page-without-adding-it-to-the-menu works great.

    Basically they recommend using the add_submenu_page() function with a NULL value for the $parent_slug parameter.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Register an admin page, but don't show it on any menu’ is closed to new replies.