Use the action update_option_{$option}
, where $option
is the same as the second argument for register_setting()
. This hook fires after the option has been updated.
add_filter( 'update_option_directory', 'run_after_change', 10, 2 );
function run_after_change( $old_value, $new_value )
{
// compare both values and do something
}
10
is the priority, 2
the number of accepted arguments for the callback function.
The opposite is pre_update_option_$option
, which runs before the option is updated. It sends the same two parameters.