0

I am doing some practice for WordPress plugin. In plugin I am working on a form and what I need is to call another page on submission. I have tried that but nothing seems to work.

<form method = "Post" action = "some_file.php">

</form>
  • Where is this form located? On WordPress admin or on the front end? – sri Jul 2 '14 at 9:33
  • 1
    Form is inside a plugin in a file. It is accessed from admin panel and open a new page. – Shah Jul 2 '14 at 10:26
1

Wordpress has a generic handler to deal with all forms - admin-post.php.

If you include a hidden field in your form called action, you can then hook in to a function of your choice with all the goodness of wordpress included.

echo "<form action='".get_admin_url()."admin-post.php' method='post'>";
echo "<input type='hidden' name='action' value='submit-form' />";
echo "<input type='hidden' name='hide' value='$ques' />";
{ Enter the rest of your first block of code from above here }

And then in your functions.php file (or any other php file that you have included via functions.php), you can use this method.

add_action('admin_post_submit-form', '_handle_form_action'); // If the user is logged in
add_action('admin_post_nopriv_submit-form', '_handle_form_action'); // If the user in not logged in
function _handle_form_action(){

    { Enter your second block of code from above here }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.