PHP – Custom Registration Form is not running working as expected

I am trying to automatically create a new site/blog when a user registers. I am using using a hook function as shown below. It works fine when using default forms, but not when I use my custom user registration form. The form adds the new users however a new site is not created for the user.

add_action( 'user_register', 'user_registration_create_site', 10, 1 );

function user_registration_create_site( $user_id ) {

$user_info = get_userdata( $user_id );
if ( isset( $user_info->user_login ) ) {
$main_site = ''; // Add your main domain here
wpmu_create_blog( $main_site, '/'.$user_info->user_login.'/', $user_info->user_login, $user_id , array( 'public' => 1 ) );