1

I am a new to Wordpress and I am trying to develop a plugin. All the plugin needs to do is provide an html form for a back end user to fill out then submit. Once the user hits submit on the form, I want to perform an sql query.

I have the form being created as a tool. But I cannot get the function to execute when the form is submitted. I've read the documentation for admin_post_custom_action. At this point, I am simply trying to get something to dump to the error log so I can see that the function is being called. My code is below. The error_log dump works in the initiation portion of the code, so I know my error logging is set up appropriately. Any guidance as to how to get this working would be greatly appreciated.

if (is_admin())
{
    add_action('admin_menu', 'nbn_page_creation_admin_menu');           
    add_action('admin_post_nbn_page_creation_create_page', 'prefix_nbn_page_creation_create_page');
}

function nbn_page_creation_admin_menu() {
    add_submenu_page('tools.php', 'NBN Page Creation', 'NBN Page Creation', 'administrator', 'nbn-page-creation', 'nbn_page_creation_html_page');
}

function prefix_nbn_page_creation_create_page(){
    error_log("Form Submitted!");
}

function nbn_page_creation_html_page() {
    // HTML CODE IS GENERATED SUCCESSFULLY TO THE TOOL PAGE VIA THIS BLOCK THERE IS NO ACTION ON MY FORM ELEMENT BECAUSE WHEN I TRIED TO DO IT ACCORDING TO THE DOCUMENTATION IT SENT ME TO AN EMPTY PHP FILE
}
2
  • 1
    What does you form action, method, and type look like.
    – Wyck
    Feb 13, 2015 at 15:48
  • i have left the action out so that the form posts against itself and the mehtod is post. for some reason the html code won't post on here... or at least I can't figure it out.
    – David Webb
    Feb 13, 2015 at 16:39

1 Answer 1

-1

Have you checked out the following:

Trigger custom action when setting button pressed

Seems like a similar situation.

Also, have you thought about having the form submit to itself and watching for the $_REQUEST variables?

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .