WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/wpmu new blog

Description

wpmu_new_blog is an action triggered whenever a new blog is created within a multisite network.

Usage

<?php add_action( 'wpmu_new_blog', 'function_name' ); ?>

where "function_name" is the name of the function to be called.

Within a class, use the following syntax;

<?php add_action( 'wpmu_new_blog', array( $this, 'function_name' ) ); ?>

Parameters

$blog_id
(int) (optional) Blog ID of the created blog.
Default: None
$user_id
(int) (required) User ID of the user creating the blog.
Default: None
$domain
(string) (optional) Domain used for the new blog.
Default: None
$path
(string) (optional) Path to the new blog.
Default: None
$site_id
(int) (optional) Site ID. Only relevant on multi-network installs.
Default: None
$meta
(array) (optional) Meta data. Used to set initial site options.
Default: None

Example

/**
 * Example of wpmu_new_blog usage
 * 
 * @param int    $blog_id Blog ID.
 * @param int    $user_id User ID.
 * @param string $domain  Site domain.
 * @param string $path    Site path.
 * @param int    $site_id Site ID. Only relevant on multi-network installs.
 * @param array  $meta    Meta data. Used to set initial site options.
 */
function wporg_wpmu_new_blog_example( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
	if ( 5 == $user_id ) {
		// Give this user some special treatment because we love them
	}
}
add_action( 'wpmu_new_blog', 'wporg_wpmu_new_blog_example', 10, 6 );

Source File

The wpmu_new_blog hook is found in wp-includes/ms-functions.php within the wpmu_create_blog() function.