I have a form which does

<form method="post" action="options.php">
<input type="submit" class="button-primary" value="<?php _e( 'Save changes', 'bsp_style_settings' ); ?>" />

I have all the register settings/admin_init's etc. and it all works fine and saves the data to WP_Options part of the database- great !

All I want to do is add an additional function that is also carried out on submit. So simple call to say

function also_do () {

so this function also executes when save is pressed.

Any suggestions on how to solve this?


2 Answers 2


You could just do a check for settings updated, and call a function.

At the top of the page that renders the settings form:

if ( isset( $_GET['settings-updated'] ) && $_GET['settings_updated'] == true ) {

Then define the custom function in your functions.php or add it to a class.

  • 1
    The settings-updated query is added after the form has submitted, in a new request. The process: form is submitted, server handles the data, browser is redirected to ?settings-updated=1. This is so that pressing F5 doesn't submit the information again, which might cause problems. This method should be avoided or, at the very least, used carefully. Also mind that if 'settings-updated' is set, the form data you submitted will NOT be present (as I said, it's a new request following a redirect). Oct 13, 2014 at 20:57
  • Yes, but for the purposes of the question, it is a quick-and-dirty way to fire off a custom function. The data is available through the options as opposed to the $_REQUEST, which is ideal as it has already been sanitized and can be safely passed to other functions (assuming it was sanitized properly).
    – member8888
    Oct 24, 2014 at 19:39

You can use the updated_option hook.

From the docs:

do_action( 'updated_option', string $option, mixed $old_value, mixed $value )

Fires after the value of an option has been successfully updated.

There is also the update_option hook which fires before an option is updated.

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.