How to add a secondary button to a settings page with a custom action?


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.

, George Edison 4 years 2020-03-09T23:50:49-05:00 0 Answers 125 views 0

Leave an answer