Register an admin page, but don't show it on any menu (5 posts)

  1. David Gard
    Posted 3 years ago #

    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?


  2. esmi
    Forum Moderator
    Posted 3 years ago #

    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?

  3. David Gard
    Posted 3 years ago #

    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(
        __('Edit Chart'),
        __('Edit Chart'),
        array(&$this, 'on_show_page')

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

  4. David Gard
    Posted 3 years ago #

    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.


  5. amereservant
    Posted 3 years ago #

    Hey duck__boy,
    The solution at http://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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.