add_option
Action HookDescription
Fires before an option is added.Hook Information
File Location |
wp-includes/option.php
View on GitHub
|
Hook Type | Action |
Line Number | 1141 |
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
add_action('add_option', 'my_custom_function', 10, 2);
function my_custom_function($option, $value) {
// Your custom code here
}
Source Code Context
wp-includes/option.php:1141
- How this hook is used in WordPress core
<?php
1136 * @since 2.9.0
1137 *
1138 * @param string $option Name of the option to add.
1139 * @param mixed $value Value of the option.
1140 */
1141 do_action( 'add_option', $option, $value );
1142
1143 $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload ) );
1144 if ( ! $result ) {
1145 return false;
1146 }
PHP Documentation
<?php
/**
* Fires before an option is added.
*
* @since 2.9.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.