Ticket #9568: 9568.2.diff
| File 9568.2.diff, 7.6 KB (added by , 17 years ago) |
|---|
-
wp-login.php
205 205 $user_email = apply_filters( 'user_registration_email', $user_email ); 206 206 207 207 // Check the username 208 if ( $user_login == '' )209 $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));210 elseif ( !validate_username( $user_login ) ) {211 $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));212 $user_login = '';213 } elseif ( username_exists( $user_login ) )214 $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));208 if ( !empty($user_login) ) { 209 if ( !validate_username( $user_login ) ) { 210 $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.')); 211 $user_login = ''; 212 } elseif ( username_exists( $user_login ) ) 213 $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.')); 214 } 215 215 216 216 // Check the e-mail address 217 217 if ($user_email == '') { … … 222 222 } elseif ( email_exists( $user_email ) ) 223 223 $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.')); 224 224 225 if ( !$errors->get_error_code() && empty($user_login) ) 226 $user_login = $user_email; 227 225 228 do_action('register_post', $user_login, $user_email, $errors); 226 229 227 230 $errors = apply_filters( 'registration_errors', $errors ); … … 373 376 374 377 <form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post"> 375 378 <p> 376 <label><?php _e('Username ') ?><br />379 <label><?php _e('Username (optional)') ?><br /> 377 380 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" tabindex="10" /></label> 378 381 </p> 379 382 <p> … … 466 469 <?php if ( !isset($_GET['checkemail']) || !in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?> 467 470 <form name="loginform" id="loginform" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post"> 468 471 <p> 469 <label><?php _e('Username ') ?><br />472 <label><?php _e('Username or E-mail') ?><br /> 470 473 <input type="text" name="log" id="user_login" class="input" value="<?php echo $user_login; ?>" size="20" tabindex="10" /></label> 471 474 </p> 472 475 <p> -
wp-includes/registration.php
188 188 $user_nicename = $alt_user_nicename; 189 189 } 190 190 191 $data = compact( 'user_ pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );191 $data = compact( 'user_login', 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 192 192 $data = stripslashes_deep( $data ); 193 193 194 194 if ( $update ) { 195 195 $wpdb->update( $wpdb->users, $data, compact( 'ID' ) ); 196 196 $user_id = (int) $ID; 197 197 } else { 198 $wpdb->insert( $wpdb->users, $data + compact( 'user_login' ));198 $wpdb->insert( $wpdb->users, $data ); 199 199 $user_id = (int) $wpdb->insert_id; 200 200 } 201 201 … … 266 266 $userdata['user_pass'] = wp_hash_password($userdata['user_pass']); 267 267 } 268 268 269 // Keep trace of current user 270 $current_user = wp_get_current_user(); 271 269 272 // Merge old and new fields with new fields overwriting old ones. 270 273 $userdata = array_merge($user, $userdata); 271 274 $user_id = wp_insert_user($userdata); 272 275 273 276 // Update the cookies if the password changed. 274 $current_user = wp_get_current_user();275 277 if ( $current_user->id == $ID ) { 276 if ( isset($plaintext_pass) ) {278 if ( isset($plaintext_pass) || $user['user_login'] != $userdata['user_login'] ) { 277 279 wp_clear_auth_cookie(); 278 280 wp_set_auth_cookie($ID); 279 281 } -
wp-admin/includes/user.php
129 129 130 130 $errors = new WP_Error(); 131 131 132 /* checking that username has been typed */133 if ( $user->user_login == '' )134 $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ));135 136 132 /* checking the password has been typed twice */ 137 133 do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 )); 138 134 … … 159 155 if (!empty ( $pass1 )) 160 156 $user->user_pass = $pass1; 161 157 162 if ( !$update && !validate_username( $user->user_login ) ) 163 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); 158 if ( !$update && !empty($user->user_login) ) { 159 if ( !validate_username( $user->user_login ) ) 160 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); 161 if ( username_exists( $user->user_login ) ) 162 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); 163 } 164 164 165 if (!$update && username_exists( $user->user_login ))166 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ));167 168 165 /* checking e-mail address */ 169 166 if ( empty ( $user->user_email ) ) { 170 167 $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); … … 177 174 if ( $errors->get_error_codes() ) 178 175 return $errors; 179 176 177 if ( $update && $userdata->user_login == $userdata->user_email ) { 178 $user->user_login = $user->user_email; 179 } elseif ( !$update && empty($user->user_login) ) { 180 $user->user_login = $user->user_email; 181 } 182 180 183 if ( $update ) { 181 184 $user_id = wp_update_user( get_object_vars( $user )); 182 185 } else { -
wp-admin/user-new.php
89 89 } 90 90 ?> 91 91 <table class="form-table"> 92 <tr class="form-field form-required">93 <th scope="row"><label for="user_login"><?php _e('Username ( required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th>94 <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true"/></td>92 <tr class="form-field"> 93 <th scope="row"><label for="user_login"><?php _e('Username (optional)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th> 94 <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" /></td> 95 95 </tr> 96 96 <tr class="form-field"> 97 97 <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th> -
wp-admin/user-edit.php
246 246 <h3><?php _e('Name') ?></h3> 247 247 248 248 <table class="form-table"> 249 <?php if ( $profileuser->user_login != $profileuser->user_email ) : ?> 249 250 <tr> 250 251 <th><label for="user_login"><?php _e('Username'); ?></label></th> 251 252 <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" class="regular-text" /> <?php _e('Your username cannot be changed.'); ?></td> 252 253 </tr> 253 254 <?php endif; ?> 254 255 <?php if ( !$is_profile_page ): ?> 255 256 <tr><th><label for="role"><?php _e('Role:') ?></label></th> 256 257 <td><select name="role" id="role">