WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. David Gard
    Member
    Posted 1 year 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?

    Thanks.

  2. esmi
    Forum Moderator
    Posted 1 year 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
    Member
    Posted 1 year 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(
        '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().

  4. David Gard
    Member
    Posted 1 year 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.

    Thanks.

  5. amereservant
    Member
    Posted 1 year 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

Tags

No tags yet.