Filter hook 'pre_add_site_option_{$option}'

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

View Source

pre_add_site_option_{$option}

Filter Hook
Description
Filters the value of a specific network option before it is 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 Filter
Line Number 2165

Hook Parameters

Type Name Description
mixed $value Value of network option.
string $option Option name.
int $network_id ID of the network.

Usage Examples

Basic Usage
<?php
// Hook into pre_add_site_option_{$option}
add_filter('pre_add_site_option_{$option}', 'my_custom_filter', 10, 3);

function my_custom_filter($value, $option, $network_id) {
    // Your custom filtering logic here
    return $value;
}

Source Code Context

wp-includes/option.php:2165 - How this hook is used in WordPress core
<?php
2160  	 *
2161  	 * @param mixed  $value      Value of network option.
2162  	 * @param string $option     Option name.
2163  	 * @param int    $network_id ID of the network.
2164  	 */
2165  	$value = apply_filters( "pre_add_site_option_{$option}", $value, $option, $network_id );
2166  
2167  	$notoptions_key = "$network_id:notoptions";
2168  
2169  	if ( ! is_multisite() ) {
2170  		$result = add_option( $option, $value, '', false );

PHP Documentation

<?php
/**
	 * Filters the value of a specific network option before it is added.
	 *
	 * The dynamic portion of the hook name, `$option`, refers to the option name.
	 *
	 * @since 2.9.0 As 'pre_add_site_option_' . $key
	 * @since 3.0.0
	 * @since 4.4.0 The `$option` parameter was added.
	 * @since 4.7.0 The `$network_id` parameter was added.
	 *
	 * @param mixed  $value      Value of network option.
	 * @param string $option     Option name.
	 * @param int    $network_id ID of the network.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/option.php
Related Hooks

Related hooks will be displayed here in future updates.