$new_user_email =
wp_unslash( $_REQUEST['email'
] );
$user_details =
wpmu_validate_user_signup( $_REQUEST['user_login'
],
$new_user_email );
if ( is_wp_error( $user_details['errors'
] ) &&
$user_details['errors'
]->
has_errors() ) { $add_user_errors =
$user_details['errors'
];
} else { /** This filter is documented in wp-includes/user.php */
$new_user_login =
apply_filters( 'pre_user_login',
sanitize_user( wp_unslash( $_REQUEST['user_login'
] ), true
) );
if ( isset( $_POST['noconfirmation'
] ) &&
current_user_can( 'manage_network_users'
) ) { add_filter( 'wpmu_signup_user_notification', '__return_false'
); // Disable confirmation email.
add_filter( 'wpmu_welcome_user_notification', '__return_false'
); // Disable welcome email.
} wpmu_signup_user( $new_user_login,
$new_user_email,
array
( 'add_to_blog' =>
get_current_blog_id(),
'new_role' =>
$_REQUEST['role'
],
) );
if ( isset( $_POST['noconfirmation'
] ) &&
current_user_can( 'manage_network_users'
) ) { $key =
$wpdb->
get_var( $wpdb->
prepare( "SELECT activation_key FROM {
$wpdb->signups
} WHERE user_login = %s AND user_email = %s",
$new_user_login,
$new_user_email ) );
$new_user =
wpmu_activate_signup( $key );
if ( is_wp_error( $new_user ) ) {