This isn't an actual question, but since I was looking for this stuff before, I thought it might be potentially useful for someone else. All of the following mainly applies for the manual creation of blogs in Site Admin -> Blogs, as opposed to users signing up for an account.
What I first noticed is that the blog address field doesn't check for invalid characters, so it's possible to create blogs with spaces and other symbols that will cause them to not load properly. To fix this, open wp-includes/wpmu-functions.php, and find the function called function wpmu_create_blog.
below
if( empty($path) )
$path = '/';
add
if ((!ereg("[A-Za-z0-9|-|_]",$path)) && (ereg("[!-)+=\';\|\\¦-Ã]",$path)))
return new WP_Error('blog_name_', __("The Blog Address contains one or more invalid characters. Please return and try again."));
$path = ereg_replace(' ','_',$path);
$path = stripslashes($path);
Another thing you'll notice is that when you create a blog, the username is exactly the same as the blog address itself. Not everyone likes to have their path and user the same, so why not provide the option. While I'm at it, I'll also tell you how you can add an extra field to specify the password, and a checkbox that allows you to choose whether to forward the notification e-mail or not (perhaps you want to set up a few things for a specific client before letting them know it's ready). You don't have to add all these options though, it's your choice (I thank Andrej for some tips).
In wp-admin/wpmu-blogs.php, at the bottom of the page where there's a cell for the admin email, add the following under it:
$username = wp_specialchars($blog['username'] ); //.
$password = wp_specialchars($blog['password'] ); //.
if ( empty($domain) || empty($email))
wp_die( __('Missing blog address or email address.') );
if( !is_email( $email ) )
wp_die( __('Invalid email address') );
if ( empty($username) || empty($password))
wp_die( __('Missing username or password.') );
if ((!ereg("[A-Za-z0-9|-|_]",$username)) && (ereg("[!-)+=\';\|\\¦-Ã]",$username)))
wp_die( __('Invalid username') );
$username = ereg_replace(' ','_',$username);
$username = stripslashes($username);
if( constant('VHOST') == 'yes' ) {
$newdomain = $domain.".".$current_site->domain;
$path = $base;
} else {
$newdomain = $current_site->domain;
$path = $base.$domain.'/';
}
//$password = 'N/A';
$user_id = email_exists($email);
if( !$user_id ) {
//$password = generate_random_password();
$user_id = wpmu_create_user( $username, $password, $email );
if(false == $user_id) {
wp_die( __('There was an error creating the user') );
} else {
if($blog['notify']) {
wp_new_user_notification($user_id, $password);
}
}
}
$wpdb->hide_errors();
$id = wpmu_create_blog($newdomain, $path, $title, $user_id , array( "public" => 1 ), $current_site->id);
$wpdb->show_errors();
if( !is_wp_error($id) ) {
if( get_user_option( $user_id, 'primary_blog' ) == 1 )
update_user_option( $user_id, 'primary_blog', $id, true );
if($blog['notify']) {
$content_mail = sprintf( __( "New blog created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain.$path, stripslashes( $title ) );
wp_mail( get_site_option('admin_email'), sprintf(__('[%s] New Blog Created'), $current_site->site_name), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
wpmu_welcome_notification( $id, $user_id, $password, $title, array( "public" => 1 ) );
}
wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add-blog'), $_SERVER['HTTP_REFERER'] ) );
exit();
} else {
wp_die( $id->get_error_message() );
}
break;
From my tests everything works as it should, the only thing to take into account is that the blog and the user are technically created separately, so if you have odd characters in the username but not the blog address, then the blog will still be created without the user, and vice-versa.