I think I deleted my post somehow, so I will post it again.
Put the code in a plugin.
This code changes the message, hides the form and makes it to not work for users with at least 5 sites that are not super admin.
Let me know if you have questions. You will need to test it and improve it more, since I did it quickly and not perfectly.
if ( 'wp-signup.php' === $GLOBALS['pagenow'] || '/wp-signup.php' === $_SERVER['PHP_SELF'] ) {
add_filter( 'gettext', 'my_change_blog_signup_function', 20, 3 );
add_action( 'wp_head', 'my_custom_css_for_wp_signup' );
add_filter( 'wpmu_validate_blog_signup', 'my_validation_for_wp_signup' );
}
function my_change_blog_signup_function( $translated_text, $untranslated_text, $domain ) {
if ( $untranslated_text == 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' && ! current_user_can( 'manage_network' ) ) {
$translated_text = 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. You can have up to 5 sites.';
$user_blogs = get_blogs_of_user( get_current_user_id() );
if ( count( $user_blogs ) >= 5 ) {
$translated_text .= '<br> <b>You cannot add more sites!</b>';
}
}
return $translated_text;
}
function my_custom_css_for_wp_signup() {
if ( is_user_logged_in() ) {
$user_blogs = get_blogs_of_user( get_current_user_id() );
if ( count( $user_blogs ) >= 5 && ! current_user_can( 'manage_network' ) ) {
echo '<style> #setupform { display: none; } </style>';
}
}
}
function my_validation_for_wp_signup( $content ) {
if ( is_user_logged_in() ) {
$user_blogs = get_blogs_of_user( get_current_user_id() );
if ( count( $user_blogs ) >= 5 && ! current_user_can( 'manage_network' ) ) {
$content['errors']->add( 'my_awesome_error', 'limit to 5 sites' );
}
}
return $content;
}