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"';
settings_fields('myplugin_settings');
do_settings_sections('myplugin');
echo 'p';
submit_button('Test Settings', '', 'test', false);
echo ' ';
submit_button(null, 'primary', 'submit', false);
echo '/p/form';
This produces two buttons, as expected:
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.
Topic settings-api plugin-development Wordpress
Category Web