Action hook 'add_option_{$option}'

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

View Source

add_option_{$option}

Action Hook
Description
Fires after a specific option has been added. The dynamic portion of the hook name, `$option`, refers to the option name.

Hook Information

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

Hook Parameters

Type Name Description
string $option Name of the option to add.
mixed $value Value of the option.

Usage Examples

Basic Usage
<?php
// Hook into add_option_{$option}
add_action('add_option_{$option}', 'my_custom_function', 10, 2);

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

Source Code Context

wp-includes/option.php:1177 - How this hook is used in WordPress core
<?php
1172  	 * @since 3.0.0
1173  	 *
1174  	 * @param string $option Name of the option to add.
1175  	 * @param mixed  $value  Value of the option.
1176  	 */
1177  	do_action( "add_option_{$option}", $option, $value );
1178  
1179  	/**
1180  	 * Fires after an option has been added.
1181  	 *
1182  	 * @since 2.9.0

PHP Documentation

<?php
/**
	 * Fires after a specific option has been added.
	 *
	 * The dynamic portion of the hook name, `$option`, refers to the option name.
	 *
	 * @since 2.5.0 As `add_option_{$name}`
	 * @since 3.0.0
	 *
	 * @param string $option Name of the option to add.
	 * @param mixed  $value  Value of the option.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/option.php
Related Hooks

Related hooks will be displayed here in future updates.