I have written a plugin that interfaces with a third-party mailing API. I have created a settings page for my plugin that includes two buttons:

  • a submit button created with submit_button() which saves the form
  • a "test settings" button that should use the current values from the form without saving them

This is what I currently have:

echo '<form method="post" action="options.php">';
echo '<p>';
submit_button('Test Settings', '', 'test', false);
echo ' ';
submit_button(null, 'primary', 'submit', false);
echo '</p></form>';

This produces two buttons, as expected:

enter image description here

However, I don't know how to override the action for the "test settings" button. Is there a hook for this? I can't find any documentation for this.

  • 1
    Just use different formaction attributes on the buttons.
    – fuxia
    Jul 19, 2016 at 2:06
  • @toscho - interesting - wasn't familiar with "formaction" attribute, but hard to find documentation on how specifically to use it in a case where the second button is also submitting a variable for action of the same type (i.e., submitting a discrete POST variable from same page)
    – CK MacLeod
    Jul 20, 2016 at 20:56
  • I had the same problem, then I found the following guide. Hopefully, this will help you as well: https://www.sitepoint.com/handling-post-requests-the-wordpress-way/
    – egillanton
    Nov 2, 2020 at 14:11

1 Answer 1


It's not clear to me what the "test" button is for, which I guess could make a difference, but, in general, I have found that to make two buttons work independently on the same options page, the easiest thing is to place them within two separately defined forms, even if the two buttons are going to be placed side by side.

The simplest method is just to create a "mini-form" for the "special" button, and, if need be use a little CSS to place the second button before or above, etc., the "primary" button. So, depending on what else is going on where you are placing the button, if you really need and want the test button to appear first, you could float it to the left. Also, you should note that, though you can style the button produced by "submit_button" using optional parameters ("type," "attribute" - see Codex), you aren't obligated to use it with the Settings API: You can produce the same button, and then add whatever selectors or element-styles, with the regular old button html that submit_button() produces.

So, mainly to illustrate:

echo '<form method="post" action="options.php">';



echo '<p>';

submit_button(null, 'primary', 'submit', false);

echo '</form>';

echo '
    <form method="post" name="test-button">

         <span id="test-button">

              <input id="test-settings" type="submit" value="Test Settings" class="button" >



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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