The customize_post_value_set_{$setting_id} WordPress PHP action fires when a specific setting’s unsanitized post value has been set using the WP_Customize_Manager::set_post_value() method. The dynamic portion of the hook name, $setting_id, refers to the setting ID.
Usage
add_action( 'customize_post_value_set_{$setting_id}', 'your_custom_function', 10, 2 );
function your_custom_function( $value, $manager ) {
// Your custom code here
}
Parameters
$value(mixed): Unsanitized setting post value.$manager(WP_Customize_Manager): WP_Customize_Manager instance.
More information
See WordPress Developer Resources: customize_post_value_set_{$setting_id}
Examples
Log setting changes
Log changes to a specific setting, such as 'blogname'.
add_action( 'customize_post_value_set_blogname', 'log_setting_changes', 10, 2 );
function log_setting_changes( $value, $manager ) {
error_log( "Blog name changed to: {$value}" );
}
Update option when setting is updated
Update another option when a specific setting, such as 'blogdescription', is updated.
add_action( 'customize_post_value_set_blogdescription', 'update_option_on_setting_change', 10, 2 );
function update_option_on_setting_change( $value, $manager ) {
update_option( 'another_option', $value );
}
Send an email when a setting is changed
Send an email notification when a specific setting, such as 'admin_email', is updated.
add_action( 'customize_post_value_set_admin_email', 'send_email_on_setting_change', 10, 2 );
function send_email_on_setting_change( $value, $manager ) {
wp_mail( '[email protected]', 'Admin Email Changed', "The new admin email is: {$value}" );
}
Modify the value before saving
Modify the value of a specific setting, such as 'default_pingback_flag', before saving it.
add_action( 'customize_post_value_set_default_pingback_flag', 'modify_value_before_saving', 10, 2 );
function modify_value_before_saving( $value, $manager ) {
if ( $value == '1' ) {
$manager->set_post_value( 'default_pingback_flag', '0' );
}
}
Run a function when a custom setting is updated
Run a function when a custom setting, such as 'my_custom_setting', is updated.
add_action( 'customize_post_value_set_my_custom_setting', 'run_function_on_custom_setting_change', 10, 2 );
function run_function_on_custom_setting_change( $value, $manager ) {
your_custom_function( $value );
}