Skip to main content
added 160 characters in body
Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

You have to POST the data somehow, or send it via GET (not good if you have a lot of data, and not really the intended purpose of GET anyway).

It is really hard to tell exactly what your problem is though. The options that come to my mind are:

  1. Use the AJAX API (even if the request isn't my by Javascript).
  2. Submit to the page you've already created.

Submitting to a different page is tricky if you need WordPress functions, and probably not worth the effort.

I'd use option #2. You can process the form in the same block of code that creates the plugin page, but if you need to redirect (PRG) you will need to hook the processing function into an early hook. Look at the wp-admin/admin.php file. Starting about halfway down you start to get a bunch of hooks beginning with the very general admin_init but also including some very specific hooks like 'load-' . $page_hook and 'load-' . $plugin_page.

Edit: Based on the code you added to the question, use the AJAX API. Also, your markup is malformed-- you need quotes around the option value attribute.

You have to POST the data somehow, or send it via GET (not good if you have a lot of data, and not really the intended purpose of GET anyway).

It is really hard to tell exactly what your problem is though. The options that come to my mind are:

  1. Use the AJAX API (even if the request isn't my by Javascript).
  2. Submit to the page you've already created.

Submitting to a different page is tricky if you need WordPress functions, and probably not worth the effort.

I'd use option #2. You can process the form in the same block of code that creates the plugin page, but if you need to redirect (PRG) you will need to hook the processing function into an early hook. Look at the wp-admin/admin.php file. Starting about halfway down you start to get a bunch of hooks beginning with the very general admin_init but also including some very specific hooks like 'load-' . $page_hook and 'load-' . $plugin_page.

You have to POST the data somehow, or send it via GET (not good if you have a lot of data, and not really the intended purpose of GET anyway).

It is really hard to tell exactly what your problem is though. The options that come to my mind are:

  1. Use the AJAX API (even if the request isn't my by Javascript).
  2. Submit to the page you've already created.

Submitting to a different page is tricky if you need WordPress functions, and probably not worth the effort.

I'd use option #2. You can process the form in the same block of code that creates the plugin page, but if you need to redirect (PRG) you will need to hook the processing function into an early hook. Look at the wp-admin/admin.php file. Starting about halfway down you start to get a bunch of hooks beginning with the very general admin_init but also including some very specific hooks like 'load-' . $page_hook and 'load-' . $plugin_page.

Edit: Based on the code you added to the question, use the AJAX API. Also, your markup is malformed-- you need quotes around the option value attribute.

Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

You have to POST the data somehow, or send it via GET (not good if you have a lot of data, and not really the intended purpose of GET anyway).

It is really hard to tell exactly what your problem is though. The options that come to my mind are:

  1. Use the AJAX API (even if the request isn't my by Javascript).
  2. Submit to the page you've already created.

Submitting to a different page is tricky if you need WordPress functions, and probably not worth the effort.

I'd use option #2. You can process the form in the same block of code that creates the plugin page, but if you need to redirect (PRG) you will need to hook the processing function into an early hook. Look at the wp-admin/admin.php file. Starting about halfway down you start to get a bunch of hooks beginning with the very general admin_init but also including some very specific hooks like 'load-' . $page_hook and 'load-' . $plugin_page.