Action hook 'pre_delete_site_option_{$option}'

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

View Source

pre_delete_site_option_{$option}

Action Hook
Description
Fires immediately before a specific network option is deleted. 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 2287

Hook Parameters

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

Usage Examples

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

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

Source Code Context

wp-includes/option.php:2287 - How this hook is used in WordPress core
<?php
2282  	 * @since 4.7.0 The `$network_id` parameter was added.
2283  	 *
2284  	 * @param string $option     Option name.
2285  	 * @param int    $network_id ID of the network.
2286  	 */
2287  	do_action( "pre_delete_site_option_{$option}", $option, $network_id );
2288  
2289  	if ( ! is_multisite() ) {
2290  		$result = delete_option( $option );
2291  	} else {
2292  		$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );

PHP Documentation

<?php
/**
	 * Fires immediately before a specific network option is deleted.
	 *
	 * The dynamic portion of the hook name, `$option`, refers to the option name.
	 *
	 * @since 3.0.0
	 * @since 4.4.0 The `$option` parameter was added.
	 * @since 4.7.0 The `$network_id` parameter was added.
	 *
	 * @param string $option     Option name.
	 * @param int    $network_id ID of the network.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/option.php
Related Hooks

Related hooks will be displayed here in future updates.