WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/pre update option (option name)

Description

This filter is applied the option value before being saving to the database to allow overriding the value to be stored. To use this filter, you will need to add filters for specific options names, such as "pre_update_option_foo" to filter the option "foo".

Parameters

$new_value
(mixed) (required) The new value.
Default: None
$old_value
(mixed) (required) The old value.
Default: None

Examples

function myplugin_update_field_foo( $new_value, $old_value ) {
	$new_value = intval( $new_value );
	$new_value ++;
	return $new_value;
}

function myplugin_init() {
	add_filter( 'pre_update_option_foo', 'myplugin_update_field_foo', 10, 2 );
}

add_action( 'init', 'myplugin_init' );

Source File

The pre_update_option_(option_name) hook is located in wp-includes/option.php, line 228

Related

Action Hooks

Filter Hooks

See Also

Plugin_API/Filter_Reference