Postback URL in WordPress Admin Page
As a wordpress plugin developer, it is very handy to provide an option page or admin page for your plugin, in essence this page is a standard php page, you can do postback to collect user data to save them in the database or for what ever reason.
Either it is complex form with a lot of input fields or the wordpress built in options settings api with just a handful of fields, you will need to set the action url for this form to indicate which php to handle the post back, here it needs some special attention that if the action url is not satisfying wordpress admin menu security, you will likely get a greeting like :
You do not have sufficient permissions to access this page
Because wordpress ‘requires all plugin page requests (?page=) to be for registered plugins pages’
So the url must be like :
<form method="post" action="/wp-admin/admin.php?page=yourplugin.php"> </form>
You can replace admin.php with options.php or options-general.php, you can not access yourplugin.php directly, and it has to have ‘page=’ as a parameter of query string.
On the other hand, if there is typo in ‘yourplugin.php’ or the plugin file does not exist, you also get the above error message rather than ‘file does not exist’. Because the page mentioned in ‘page=’ must be a registered plugin.
Another handy way to set action:
<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>"> </form>