Ticket #39123: 39123.patch
File 39123.patch, 3.4 KB (added by , 7 years ago) |
---|
-
wp-admin/includes/user.php
39 39 $update = false; 40 40 } 41 41 42 if ( !$update &&isset( $_POST['user_login'] ) )42 if ( isset( $_POST['user_login'] ) ) 43 43 $user->user_login = sanitize_user($_POST['user_login'], true); 44 44 45 45 $pass1 = $pass2 = ''; -
wp-admin/user-edit.php
368 368 <table class="form-table"> 369 369 <tr class="user-user-login-wrap"> 370 370 <th><label for="user_login"><?php _e('Username'); ?></label></th> 371 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td>371 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" class="regular-text" <?php echo (current_user_can( 'edit_users')) ? '' : 'disabled'; ?>/></td> 372 372 </tr> 373 373 374 374 <?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?> -
wp-includes/user.php
1481 1481 } elseif ( mb_strlen( $user_login ) > 60 ) { 1482 1482 return new WP_Error( 'user_login_too_long', __( 'Username may not be longer than 60 characters.' ) ); 1483 1483 } 1484 1485 if ( ! $update && username_exists( $user_login ) ) { 1484 /* 1485 * If there is no update, just check for `username_exists`. If there is an update, 1486 * check if current email and new email are the same, or not, and check `username_exists` 1487 * accordingly. 1488 */ 1489 if ( ( ! $update || ( ! empty( $old_user_data ) && 0 !== strcasecmp( $user_login, $old_user_data->user_login ) ) ) 1490 && ! defined( 'WP_IMPORTING' ) 1491 && username_exists( $user_login ) 1492 ) { 1486 1493 return new WP_Error( 'existing_user_login', __( 'Sorry, that username already exists!' ) ); 1487 1494 } 1495 1488 1496 1489 1497 /** 1490 1498 * Filters the list of blacklisted usernames. … … 1500 1508 } 1501 1509 1502 1510 /* 1503 * If a nicename is provided, remove unsafe user characters before using it. 1504 * Otherwise build a nicename from the user_login. 1511 * Evertime build a nicename from the user_login. 1505 1512 */ 1506 if ( ! empty( $userdata['user_nicename'] ) ) { 1507 $user_nicename = sanitize_user( $userdata['user_nicename'], true ); 1508 if ( mb_strlen( $user_nicename ) > 50 ) { 1509 return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) ); 1510 } 1511 } else { 1512 $user_nicename = mb_substr( $user_login, 0, 50 ); 1513 } 1513 $user_nicename = mb_substr( $user_login, 0, 50 ); 1514 1514 1515 1515 $user_nicename = sanitize_title( $user_nicename ); 1516 1516 … … 1662 1662 1663 1663 $compacted = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 1664 1664 $data = wp_unslash( $compacted ); 1665 1666 if ( ! $update ){1667 $data = $data + compact( 'user_login' 1665 1666 if(current_user_can( 'edit_users')){ 1667 $data = $data + compact( 'user_login'); 1668 1668 } 1669 1669 1670 1670 /** … … 1861 1861 1862 1862 // Merge old and new fields with new fields overwriting old ones. 1863 1863 $userdata = array_merge( $user, $userdata ); 1864 1864 1865 $user_id = wp_insert_user( $userdata ); 1865 1866 1866 1867 if ( ! is_wp_error( $user_id ) ) {