Support » Plugins » Hacks » Adding Administration pages that do not appear on the menu.

  • I run into a small problem today. I am developing a plugin that allows you to manage events. I have an administration screen that lists the events, and each event has a link to an edit page. I do not want this page to appear on the menu. So I though it would be simple. Just add a link to for example,

    The problem here is that when I access that page, all I get is a message saying I do not have sufficient permissions to access that page. So, I decided to track down that message and find out how to solve it. It turns out that wordpress keeps track of all the pages that are registered, and if one is not, then it throws this message.

    The approach I took to solve this problem is to manually add my page to the array of registered pages, and I would like to know what you guys think about this approach.
    This is the code:

    function B_AB_registerAuxiliarPages(){
            global $_registered_pages;
            $_registered_pages['pluginfolder/auxpagefile'] = 1;
    add_action('admin_menu', 'B_AB_registerAuxiliarPages');

    Basically, what I’m doing is adding my page to $_registered_pages. You can refer to the function user_can_access_admin_page() in wp-admin/includes/plugin.php to see how and why this works.

    So, what do you guys think? Is this an acceptable approach? Is this likely to stop working at some point? is there a better way to do this?

  • The topic ‘Adding Administration pages that do not appear on the menu.’ is closed to new replies.