I’ve got this problem while developing a WordPress plugin. Here’s the code snippet of the area I’m working with:
add_submenu_page( 'admin_manager',
'Add Event',
'Add Event',
'manage_options',
'add_event&action=modify',
'add_event_handler' );
As you can see, on my menu slug I want to add the ‘&action=modify’
'add_event&action=modify'
But when I do that, WordPress denies me access and says I don’t have the proper privileges. It works fine without the extra parameters, is there something built into wordpress that doesn’t allow for such things?
Any thoughts or workarounds?
The slug argument is not intended to take in query parameters. If you’re intending to set up some kind of default action (which, I would also imagine the “action” query is more than likely a reserved keyword used by WordPress itself), why don’t you set up the page to populate as if the parameter were there by default?
My guess is that you want other parameters in place as well, which you can then use a Form to send data (via POST or GET) to populate your page using those parameters. For instance:
This isn’t a perfect example, but I’m sure you can gather what has been done here. As mentioned, the slug argument is NOT intended to populate queries, and you should also be naming your GET and POST keys (as well as option and meta keys) something unique to your code so the likelihood of any naming conflicts is minimal.
Another example of the proper use of submenu navigation without relying on a form to navigate would be something like this:
Your best bet would be to look up some examples of how plugin authors have effectively used the add_submenu_page() function, but mostly, you should play around with it and get used to how the normal WordPress flow works.
Good luck, and let me know if this helps.