Description
Fires after the site has been created. Only applicable to Network installs with the “Create Site” option enabled.
Usage
Applies to all forms.
1 | add_action( 'gform_site_created' , 'your_function_name' , 10, 5 ); |
Parameters
- $site_id integer
The ID of the created site.
-
$user_id string
The ID of the registered user.
-
$entry Entry Object
The entry object from which the site was created.
-
$feed Feed Object
The Feed which is currently being processed.
-
$password string
The password associated with the user; either submitted by the user or sent via email from WordPress.
Examples
Here is an example where we use this hook to create a new welcome post on the newly created site.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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 should be placed in the functions.php file of your active theme.
Source Code
1 | do_action( 'gform_site_created' , $blog_id , $user_id , $entry , $feed , $password ); |
This filter is located in GF_User_Registration::create_site() in class-gf-user-registration.php.