Action hook 'wp_initialize_site'

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

View Source

wp_initialize_site

Action Hook
Description
Fires when a site's initialization routine should be executed.

Hook Information

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

Hook Parameters

Type Name Description
WP_Site $new_site New site object.
array $args Arguments for the initialization.

Usage Examples

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

function my_custom_function($new_site, $args) {
    // Your custom code here
}

Source Code Context

wp-includes/ms-site.php:105 - How this hook is used in WordPress core
<?php
 100  	 * @since 5.1.0
 101  	 *
 102  	 * @param WP_Site $new_site New site object.
 103  	 * @param array   $args     Arguments for the initialization.
 104  	 */
 105  	do_action( 'wp_initialize_site', $new_site, $args );
 106  
 107  	// Only compute extra hook parameters if the deprecated hook is actually in use.
 108  	if ( has_action( 'wpmu_new_blog' ) ) {
 109  		$user_id = ! empty( $args['user_id'] ) ? $args['user_id'] : 0;
 110  		$meta    = ! empty( $args['options'] ) ? $args['options'] : array();

PHP Documentation

<?php
/**
	 * Fires when a site's initialization routine should be executed.
	 *
	 * @since 5.1.0
	 *
	 * @param WP_Site $new_site New site object.
	 * @param array   $args     Arguments for the initialization.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/ms-site.php
Related Hooks

Related hooks will be displayed here in future updates.