This filter is applied the option value before being saved 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".
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' );
The pre_update_option_(option_name) hook is located in wp-includes/option.php
, line 228