From 7629767c24ee7deb7307b9876b8c94cf44de8577 Mon Sep 17 00:00:00 2001 From: donncha Date: Thu, 29 Apr 2010 16:05:33 +0000 Subject: [PATCH] Display the original username on the signup form on error, fixes #13124 git-svn-id: http://svn.automattic.com/wordpress/trunk@14298 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-functions.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index e9e47feac..03b30a9e0 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -456,18 +456,21 @@ function wpmu_validate_user_signup($user_name, $user_email) { $errors = new WP_Error(); + $orig_username = $user_name; $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); + $maybe = array(); + preg_match( '/[a-z0-9]+/', $user_name, $maybe ); + + if ( $user_name != $orig_username || $user_name != $maybe[0] ) { + $errors->add( 'user_name', __( "Only the lowercase letters a-z and numbers allowed" ) ); + $user_name = $orig_username; + } + $user_email = sanitize_email( $user_email ); if ( empty( $user_name ) ) $errors->add('user_name', __('Please enter a username')); - $maybe = array(); - preg_match( '/[a-z0-9]+/', $user_name, $maybe ); - - if ( $user_name != $maybe[0] ) - $errors->add('user_name', __('Only lowercase letters and numbers allowed')); - $illegal_names = get_site_option( 'illegal_names' ); if ( is_array( $illegal_names ) == false ) { $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); @@ -535,7 +538,7 @@ function wpmu_validate_user_signup($user_name, $user_email) { $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.')); } - $result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors); + $result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors); return apply_filters('wpmu_validate_user_signup', $result); }