Weird question, how can I run a custom function AFTER my theme settings are saved? I see that the register_settings() function has a sanitize callback, but that runs before the settings are changed. I need something to run after they’re saved. Is there an action or filter I can use to do that?
EDIT –
SO I have this setting I made:
add_settings_section(
'kjd_body_background_settings_section', // ID hook name
null, // label
null, // function name
'kjd_body_background_settings' // page name
);
add_settings_field(
'kjd_body_background_colors', // ID hook name
null, //label
null, //callback
'kjd_body_background_settings', // page name
'kjd_body_background_settings_section' // parent section
);
and this function:
function kjd_update_stylesheet( $oldvalue, $_newvalue ){
echo 'updated!';
die();
}
add_action('update_options_kjd_body_background_settings','kjd_update_stylesheet',10, 2);
//add_action('update_options_kjd_body_background_colors','kjd_update_stylesheet',10, 2);
Use the filter
update_option_{$option}
. It runs after a successful saving.$option
is the name of your option, and you get the old and the new value as parameters.From
wp-includes/option.php
:Use it like this for an option
wpse_themesettings
: