Action hook 'update_option'

in WP Core File wp-includes/option.php at line 944

View Source

update_option

Action Hook
Description
Fires immediately before an option value is updated.

Hook Information

File Location wp-includes/option.php View on GitHub
Hook Type Action
Line Number 944

Hook Parameters

Type Name Description
string $option Name of the option to update.
mixed $old_value The old option value.
mixed $value The new option value.

Usage Examples

Basic Usage
<?php
// Hook into update_option
add_action('update_option', 'my_custom_function', 10, 3);

function my_custom_function($option, $old_value, $value) {
    // Your custom code here
}

Source Code Context

wp-includes/option.php:944 - How this hook is used in WordPress core
<?php
 939  	 *
 940  	 * @param string $option    Name of the option to update.
 941  	 * @param mixed  $old_value The old option value.
 942  	 * @param mixed  $value     The new option value.
 943  	 */
 944  	do_action( 'update_option', $option, $old_value, $value );
 945  
 946  	$update_args = array(
 947  		'option_value' => $serialized_value,
 948  	);
 949  

PHP Documentation

<?php
/**
	 * Fires immediately before an option value is updated.
	 *
	 * @since 2.9.0
	 *
	 * @param string $option    Name of the option to update.
	 * @param mixed  $old_value The old option value.
	 * @param mixed  $value     The new option value.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 3
  • File: wp-includes/option.php
Related Hooks

Related hooks will be displayed here in future updates.