Ticket #44921: 44921.diff
File 44921.diff, 1.5 KB (added by , 6 years ago) |
---|
-
wp-includes/user.php
1710 1710 1711 1711 $meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : ''; 1712 1712 1713 $user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $user_nicename, $user_login ) ); 1713 $user_args = array( 1714 'blog_id' => 0, 1715 'fields' => 'ID', 1716 'nicename' => $user_nicename, 1717 'number' => 1, 1718 'login__not_in' => array( $user_login ), 1719 ); 1714 1720 1721 $user_nicename_check = get_users( $user_args ); 1722 1715 1723 if ( $user_nicename_check ) { 1716 1724 $suffix = 2; 1717 1725 while ( $user_nicename_check ) { 1718 1726 // user_nicename allows 50 chars. Subtract one for a hyphen, plus the length of the suffix. 1719 $base_length = 49 - mb_strlen( $suffix ); 1720 $alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix"; 1721 $user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login ) ); 1727 $base_length = 49 - mb_strlen( $suffix ); 1728 $alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix"; 1729 $user_args['login__not_in'] = array( $alt_user_nicename ); 1730 $user_nicename_check = get_users( $user_args ); 1722 1731 $suffix++; 1723 1732 } 1724 1733 $user_nicename = $alt_user_nicename;