Action hook 'wp_validate_site_data'

in WP Core File wp-includes/ms-site.php at line 502

View Source

wp_validate_site_data

Action Hook
Description
Fires when data should be validated for a site prior to inserting or updating in the database. Plugins should amend the `$errors` object via its `WP_Error::add()` method.

Hook Information

File Location wp-includes/ms-site.php View on GitHub
Hook Type Action
Line Number 502

Hook Parameters

Type Name Description
WP_Error $errors Error object to add validation errors to.
array $data Associative array of complete site data. See {@see wp_insert_site()} for the included data.
WP_Site|null $old_site The old site object if the data belongs to a site being updated, or null if it is a new site being inserted.

Usage Examples

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

function my_custom_function($errors, $data, $old_site) {
    // Your custom code here
}

Source Code Context

wp-includes/ms-site.php:502 - How this hook is used in WordPress core
<?php
 497  	 * @param array        $data     Associative array of complete site data. See {@see wp_insert_site()}
 498  	 *                               for the included data.
 499  	 * @param WP_Site|null $old_site The old site object if the data belongs to a site being updated,
 500  	 *                               or null if it is a new site being inserted.
 501  	 */
 502  	do_action( 'wp_validate_site_data', $errors, $data, $old_site );
 503  
 504  	if ( ! empty( $errors->errors ) ) {
 505  		return $errors;
 506  	}
 507  

PHP Documentation

<?php
/**
	 * Fires when data should be validated for a site prior to inserting or updating in the database.
	 *
	 * Plugins should amend the `$errors` object via its `WP_Error::add()` method.
	 *
	 * @since 5.1.0
	 *
	 * @param WP_Error     $errors   Error object to add validation errors to.
	 * @param array        $data     Associative array of complete site data. See {@see wp_insert_site()}
	 *                               for the included data.
	 * @param WP_Site|null $old_site The old site object if the data belongs to a site being updated,
	 *                               or null if it is a new site being inserted.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 3
  • File: wp-includes/ms-site.php
Related Hooks

Related hooks will be displayed here in future updates.