update_option_{option-name}
update_option_{option-name} is an action run whenever an existing option is updated. It passes two parameters: the old value and the new value.
Context:
File: wp-includes/functions.php
wp_cache_set($option_name, $newvalue, 'options');
$newvalue = $wpdb->escape($newvalue);
$option_name = $wpdb->escape($option_name);
$wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'");
if ( $wpdb->rows_affected == 1 ) {
do_action("update_option_{$option_name}", $oldvalue, $newvalue);
return true;
}
return false;
This hook can pass multiple parameters. In order to get additional parameters (up to 2 for this hook) passed to your function, you will have to hook in like this: add_filter('update_option_{option-name}', 'your_function', 10, 2); where 10 is your function's priority, and 2 is the number of parameters you want your function to accept. Note that your function should only return the first parameter.
This hook is an action which means that it primarily acts as an event trigger, instead of a content filter. This is a semantic difference, but it will help you to remember what this hook does if you use it like this: add_action('update_option_{option-name}', 'your_function');
This hook was introduced in WordPress 2.0.1, and will not work in earlier versions.