pre_update_option filter-hookWP 3.9.0

Filters an option before its value is (maybe) serialized and updated.

Usage

add_filter( 'pre_update_option', 'wp_kama_pre_update_option_filter', 10, 3 );

/**
 * Function for `pre_update_option` filter-hook.
 * 
 * @param mixed  $value     The new, unserialized option value.
 * @param string $option    Name of the option.
 * @param mixed  $old_value The old option value.
 *
 * @return mixed
 */
function wp_kama_pre_update_option_filter( $value, $option, $old_value ){

	// filter...
	return $value;
}
$value(mixed)
The new, unserialized option value.
$option(string)
Name of the option.
$old_value(mixed)
The old option value.

Changelog

Since 3.9.0 Introduced.

Where the hook is called

update_option()
pre_update_option
wp-includes/option.php 787
$value = apply_filters( 'pre_update_option', $value, $option, $old_value );

Where the hook is used in WordPress

wp-includes/class-wp-customize-widgets.php 2114
add_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10, 3 );
wp-includes/class-wp-customize-widgets.php 2172
remove_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10 );