apply_filters( "pre_update_option_{$option}", mixed $value, mixed $old_value, string $option )

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

Description Description

The dynamic portion of the hook name, $option, refers to the option name.

Top ↑

Parameters Parameters


(mixed) The new, unserialized option value.


(mixed) The old option value.


(string) Option name.

Top ↑

More Information More Information

This filter is applied to the option value before being saved to the database; this allows the overriding 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“.

Top ↑

Source Source

File: wp-includes/option.php

View on Trac

Top ↑

Changelog Changelog

Version Description
4.4.0 The $option parameter was added.
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by stevenlinx

    Example migrated from Codex:

    add_action( 'init', 'myplugin_init' );
    function myplugin_init() {
    	add_filter( 'pre_update_option_foo', 'myplugin_update_field_foo', 10, 2 );
    function myplugin_update_field_foo( $new_value, $old_value ) {
    	$new_value = intval( $new_value );
    	$new_value ++;
    	return $new_value;

Top ↑

You must log in before being able to contribute a note or feedback.