Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have added some pages to the WP-Adminmenu, with add_menu_page and add_submenu_page. The URLs for those pages look like admin.php?page=my-plugin/admin/submenupage.php. If I try to add a page now that has isnt registered to the menu and link to it with <a href="?page=my-plugin/admin/add.php"> I'm getting a permissions error. Is there a way to add pages to the admin area without registering them to the menu?

share|improve this question
    
Please always show your whole code. –  kaiser Nov 21 '12 at 18:50
    
@kaiser do you miss anything? I think in this case the whole code would be more annoying since its distributed over some classes etc. –  wintersolutions Nov 21 '12 at 20:20
add comment

1 Answer 1

up vote 1 down vote accepted

The best thing you can do here is to call them with a $_GET parameter, and just register the first site to the menu.

so for example, when you registered admin.php?page=my-plugin/admin/submenupage.php, you have the submenupage.php structured like this:

if ( !isset( $_GET['section'] ) ) {
     include('mainpage.php');
} else if ($_GET['section'] == 'hiddenpage1' ){
     include('mainpage.php');
} // go on for every page needed.

This way you have your registered menuentry, but by clicking it from the adminmenu you always get to the mainpage.php. Just add the &section=hiddenpage1 or whatever you call your hidden pages, and you will see the "hidden" admin sections.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.