Need Pro Site hook for post site activation

I need a hook that is triggered after the user is registered and their site is activated so I can call our API afterwords.

  • Adam Czajczyk

    Hi Kamy,

    I hope you're well today and thank you for your question!

    Upon site creation the Pro Sites plugin stores site data in the signup table so the site doesn't even exist. There's an activation code stored in signup table and only after Pro Sites activation is done (so e.g. after confirmed payment) the site is actually created and that's done using native WP routines.

    Therefore, you can use a native WP action hook "wpmu_new_blog". Take a look here, please:

    https://developer.wordpress.org/reference/hooks/wpmu_new_blog/

    I think that should do the trick :slight_smile: If you have any additional/follow up questions, let me know please and I'll be happy to assist.

    Best regards,
    Adam

  • Kamy

    Hi Adam.

    Thanks, but that's dose'nt work. I have try with this hook since the back-office -> "wpmu new user", my request work. But I want create the user whmcs when the new blog pro site and new user is create from the registration form of pro site. Nothing :slight_frown:(
    -> This request is in the function.php file.

    / Create WHMCS User when new user create new blog pro site
    function whmcs_create_user($user_id)
    {
    $user_info = get_userdata($user_id);
    // CREATE USER TO WHMCS
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $whmcsUrl . 'includes/api.php');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt(
    $ch,
    CURLOPT_POSTFIELDS,
    http_build_query( array(. .. ..))
    );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($ch);
    curl_close($ch)
    var_dump('EXECUTE ???');
    }
    add_action('wpmu_new_blog', 'whmcs_create_user');

  • Adam Czajczyk

    Hello @camille70631!

    Have you checked WP debug.log against any errors? It might be helpful to enable WP debugging with debug output to the file and check it.

    Also, assuming that your "curl code" alone is working fine, I would actually try calling it in a bit different way:

    function whmcs_create_user( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
    
    /* your "curl code" comes here */
    
    }
    add_action( 'wpmu_new_blog', 'whmcs_create_user', 10, 6 );

    That would ensure that the proper data (user id) is actually provided to the callback function and would let you also experiment with an action priority value which might be important here - I'd actually try changing default 10 to something much higher such as e.g. 99, to force later execution of the callback function.

    Would you give it a try? Let me know about results, please.

    Kind regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.