Gform site created

Available in User Registration Add-on v1.3

Description

Fires after the site has been created. Only applicable to Network installs with the "Create Site" option enabled.

Usage

Applies to all forms

<?php
add_action("gform_site_created", "custom_user_validation", 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.

$config

(array) The User Registration configuration object.

$password

(string) The password associated with the user; either submitted by the user or automatically generated.

Examples

Here is an example where we use this hook to create a new welcome post on the newly created site.


<?php
add_action("gform_site_created", "create_welcome_post", 10, 2);
function create_welcome_post($site_id, $user_id) {
        
    $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();
   
?>

Source Code

This filter is located in userregistration.php

Search the Documentation