Custom Plugin - Posting data from main page to another page within your plugin


I created a new custom plugin, that adds a new admin menu to show a list of events. When you click any given event, I want to send you to another page in my plugin that will then render information about this event. I can keep it simple and just use a query string parameter, so don't need to do a form POST, but I would be interested in that as well.

There are two pages:

<ol><li>/my-plugin/reservation-management.php</li> <li>/my-plugin/reservation-management-details.php</li> </ol>

My setup in the base page (reservation-management.php):

add_action( 'admin_menu', 'addReservationManagementMenuItem' ); function addReservationManagementMenuItem(){ add_menu_page('Reservation Management', 'Reservation Management', 'manage_options', 'reservation_management_slug', 'reservation_management_building_function','',3); }

Inside my function to build out the first screen, I render some clickable links. To simplify:

function reservation_management_building_function(){ if(!current_user_can('manage_options')){ ?> <h2>Clickable Link</h2> <?php echo("<a href='reservation-management-details.php?id=$id'>Event</a>"); ?> <?php } } ?>

I just simplified the code, removed some loop logic, etc, but it works and renders out in a loop all of the events with a url of reservation-details.php?id=x where x is the unique post id of each event.

The thing is, this just sends me to a page not found. I even tried using things like get_admin_url() etc

I think I'm missing a fundamental step in how a custom plugin can post from one page to another all while still being within wp-admin.

How can I use an href to safely send the admin user to another admin page within my plugin directory?



Has the page been declared in the plugin? It sounds like you'd need to add a submenu page to your plugin as well.

Example (<em>edited</em>):

add_action( 'admin_menu', 'addReservationManagementMenuItem' ); function addReservationManagementMenuItem(){ add_menu_page('Reservation Management', 'Reservation Management', 'manage_options', 'reservation_management_slug', 'reservation_management_building_function','',3); //add any relative submenu pages here //you can have as many submenu pages as you need //please keep in mind that add_submenu_page() requires a different set //of parameters passed to it //if you want the submenu page viewed, and your function exists on your //plugin definition page add_submenu_page('reservation-management-details.php', 'Reservation Management Details', 'Reservation Management Details', 'manage_options', 'reservation_management_details_slug'); //if you don't want your submenu page accessible in the submenu //use null as the first parameter to remove it's inclusion from the submenu //specify the php file used add_submenu_page(null, 'Reservation Management Details', 'Reservation Management Details', 'manage_options', 'reservation-management-details.php'); }

In the above example, you'd be able to post to your new page in your plugin, because you've now defined it. But often times, I find that I <em>don't</em> want anyone being able to get to a page I've designated as '_POST' only, so my first parameter is then set to <strong>null</strong>.

<em>Edit:</em> The only thing that I can't remember off the top of my head is what that POST url needs to be. Please let me know if you need assistance with that, and I'll work it out for you.

Please let me know if you have any questions.


  • Invalid parameter number given with pdo's prepared statement
  • JQuery Daterangepicker onchange event
  • Retrieving specific tuples using Mysql
  • Testing microdata in Gmail doesn't work
  • How to open target blank in a custom admin sub menu page?
  • wordpress plugin redirect from page to page permisson error
  • Copying data from a MS Access form into Excel
  • Cakephp Call to Undefined Method Set::numeric()
  • Generate a table of orders grouped by user_id which sums quantity of product
  • sql query Update INNER JOINED table
  • Splitting numbers and letters in SQL Server 2005 table
  • SSIS - SQL Server datetimeoffset(0) destination column recognized as DT_WSTR
  • TitanDB - Build a property index in descending order by timestamp
  • How to remove a list of accidently deleted databases from Sql Server Management Studio's tree-l
  • Process.StartTime Access Denied
  • Giving security priviliege to a scheduler in Java EE 6
  • How to lookup value with multiple criteria in excel 2007 and newer
  • Using SWIG with a build system [closed]
  • Installing libCurl - ruby 1.9.3 .. rails 3.2.12 .. Windows
  • What does Main.1 output file do in XCode?
  • Creating a setup.exe in InstallShield in Visual Studio
  • Backward compatibility of Python 3.5 for external modules
  • Command line installation of Code Signing certificates, .p12 files, and mobileprovisions
  • Alamofire and Reachability.swift not working on xCode8-beta5
  • Add reference to ASP.NET 5 Class Library from Framework 4.5 Class Library Project
  • python mysqldb delete row
  • Django Haystack Rebuild Index
  • Does Apportable support to build library binary (.a/.so)?
  • How to retrieve information from antrun back to maven?
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • Eclipse MTJ doesn't see Java ME SDK 3.0 devices
  • Function calls are not supported. Consider replacing the function or lambda with a reference to an e
  • Android Studio 1.3 RC3. Google Play services out of date. Requires 7571000 but found 6774470
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Unable to install Git-core+svn by MacPorts
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Convert array of 8 bytes to signed long in C++
  • -fvisibility=hidden not passed by compiler for Debug builds
  • Net Present Value in Excel for Grouped Recurring CF