gform_site_created

Description

The gform_site_created action fires after the site has been created. Only applicable to Network installs with the “Create Site” option enabled.

Usage

Applies to all forms.

add_action( 'gform_site_created', 'your_function_name', 10, 5 );

Parameters

ParameterTypeDescription
$site_idintegerThe ID of the created site.
$user_idstringThe ID of the registered user.
$entryEntry ObjectThe entry object from which the site was created.
$feedFeed ObjectThe Feed which is currently being processed.
$passwordstringThe password associated with the user; either submitted by the user or sent via email from WordPress.

Examples

Create a welcome post on the newly created site.

add_action( 'gform_site_created', 'create_welcome_post', 10, 5 );
function create_welcome_post( $site_id, $user_id, $entry, $feed, $password ) {

	$user = get_userdata( $user_id );

	$post = array();
	$post['post_title']   = 'Welcome to your new site!';
	$post['post_content'] = "Hi {$user->first_name},\nWe just wanted to personally welcome you to your new site!";

	switch_to_blog( $site_id );
	wp_insert_post( $post );
	restore_current_blog();

}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

do_action( 'gform_site_created', $blog_id, $user_id, $entry, $feed, $password );

This action is located in GF_User_Registration::create_site() in class-gf-user-registration.php.