WordPress.org

Ready to get started?Download WordPress

Forums

Adding Administration pages that do not appear on the menu. (1 post)

  1. Buzu
    Member
    Posted 2 years ago #

    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, mysite.com/wp-admin/admin.php?page=plugin/edit.php

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic