mirror of
git://develop.git.wordpress.org/
synced 2025-03-22 21:09:51 +01:00
Users: Check maximum length of user_nicename
after filters are applied.
Similar to other checks on `user_login` and `user_url`, this change moves the maximum length check on `user_nicename` after the `pre_user_nicename` filter has been applied, to account for any changes to the value prior to saving. Props SergeyBiryukov, ravipatel, muhammadfaizanhaidar, mukesh27, csesumonpro, azouamauriac. Fixes #54987. git-svn-id: https://develop.svn.wordpress.org/trunk@52954 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d35c8e8543
commit
ab7d749e19
@ -1977,9 +1977,6 @@ function wp_insert_user( $userdata ) {
|
||||
*/
|
||||
if ( ! empty( $userdata['user_nicename'] ) ) {
|
||||
$user_nicename = sanitize_user( $userdata['user_nicename'], true );
|
||||
if ( mb_strlen( $user_nicename ) > 50 ) {
|
||||
return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) );
|
||||
}
|
||||
} else {
|
||||
$user_nicename = mb_substr( $user_login, 0, 50 );
|
||||
}
|
||||
@ -1995,6 +1992,10 @@ function wp_insert_user( $userdata ) {
|
||||
*/
|
||||
$user_nicename = apply_filters( 'pre_user_nicename', $user_nicename );
|
||||
|
||||
if ( mb_strlen( $user_nicename ) > 50 ) {
|
||||
return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) );
|
||||
}
|
||||
|
||||
$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 ) );
|
||||
|
||||
if ( $user_nicename_check ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user