There is the option that you don’t allow the user to register on the main site, allowing them to register on the subsite only. The plugin network-subsite-user-registration allows this, if the user is already registered on the network then they are automatically added, by the plugin, to the site requesting registration. The hook that does this is ‘wpmu_validate_user_signup’..
// check and add users if already on the network
add_filter( 'wpmu_validate_user_signup', 'add_exting_user' );
/**
* If users are already registered with the Network then simply add them
* to this new site.
*
* @return $result or drops out
*/
function add_exting_user( $result ) {
if ( is_user_logged_in() ) {
return $result;
}
$submitted_user_email = $result['user_email'];
$original_error = $result['errors'];
foreach( $original_error->get_error_codes() as $code ){
foreach( $original_error->get_error_messages( $code ) as $message ){
if( $code != 'user_email' && $message == __( 'Sorry, that username already exists!') ){
$user = get_user_by( 'email', $submitted_user_email );
$user_id = $user->ID;
$blog_id = get_current_blog_id();
add_user_to_blog( $blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
$user_blogs = get_blogs_of_user( $user_id );
$user_blogs_sorted = array();
foreach ( $user_blogs AS $user_blog ) {
$user_blogs_sorted[ $user_blog->blogname ] = $user_blog->siteurl;
}
// A real quick way to do a case-insensitive sort of an array keyed by strings:
uksort($user_blogs_sorted , "strnatcasecmp");
$html = "<h1>";
$html .= sprintf( __('Hi %1$s you have been added to this site, your current sites on the Network are:', 'network-subsite-user-registration' ), "<strong>$submitted_user_email</Strong>" );
$html .= "</h1></Br><ul>";
foreach ( $user_blogs_sorted AS $sitename => $siteurl ) {
if ( ! is_main_site( $user_blog->userblog_id ) ) {
$html .= '<li><h2><strong><a href="' . wp_login_url($siteurl ) . '" target="_blank" >' . $sitename . '</a></strong></h2></li>';
}
}
$html .= "</ul>";
die( $html );
}
}
}
return $result;
}