diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
index 3604d94389..085e6369d8 100644
a
|
b
|
function wp_insert_user( $userdata ) { |
1971 | 1971 | return new WP_Error( 'invalid_username', __( 'Sorry, that username is not allowed.' ) ); |
1972 | 1972 | } |
1973 | 1973 | |
1974 | | /* |
1975 | | * If a nicename is provided, remove unsafe user characters before using it. |
1976 | | * Otherwise build a nicename from the user_login. |
1977 | | */ |
1978 | | if ( ! empty( $userdata['user_nicename'] ) ) { |
1979 | | $user_nicename = sanitize_user( $userdata['user_nicename'], true ); |
1980 | | if ( mb_strlen( $user_nicename ) > 50 ) { |
1981 | | return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) ); |
1982 | | } |
| 1974 | if (! empty( $userdata['user_nicename'] )) { |
| 1975 | // If a nicename is provided, remove unsafe user characters before using it. |
| 1976 | $sanitized_user_nicename = sanitize_user( $userdata['user_nicename'], true ); |
1983 | 1977 | } else { |
1984 | | $user_nicename = mb_substr( $user_login, 0, 50 ); |
| 1978 | // Otherwise build a nicename from the user_login. |
| 1979 | $sanitized_user_nicename = mb_substr( $user_login, 0, 50 ); |
1985 | 1980 | } |
1986 | 1981 | |
1987 | | $user_nicename = sanitize_title( $user_nicename ); |
1988 | | |
1989 | 1982 | /** |
1990 | 1983 | * Filters a user's nicename before the user is created or updated. |
1991 | 1984 | * |
… |
… |
function wp_insert_user( $userdata ) { |
1993 | 1986 | * |
1994 | 1987 | * @param string $user_nicename The user's nicename. |
1995 | 1988 | */ |
1996 | | $user_nicename = apply_filters( 'pre_user_nicename', $user_nicename ); |
| 1989 | $user_nicename = apply_filters( 'pre_user_nicename', $sanitized_user_nicename ); |
| 1990 | |
| 1991 | if ( mb_strlen( $user_nicename ) > 50 ) { |
| 1992 | return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) ); |
| 1993 | } |
| 1994 | |
| 1995 | $user_nicename = sanitize_title( $user_nicename ); |
1997 | 1996 | |
1998 | 1997 | $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 ) ); |
1999 | 1998 | |
… |
… |
function wp_insert_user( $userdata ) { |
2043 | 2042 | */ |
2044 | 2043 | $user_url = apply_filters( 'pre_user_url', $raw_user_url ); |
2045 | 2044 | |
| 2045 | if ( mb_strlen( $user_url ) > 100 ) { |
| 2046 | return new WP_Error( 'user_url_too_long', __( 'URL may not be longer than 100 characters.' ) ); |
| 2047 | } |
| 2048 | |
2046 | 2049 | $user_registered = empty( $userdata['user_registered'] ) ? gmdate( 'Y-m-d H:i:s' ) : $userdata['user_registered']; |
2047 | 2050 | |
2048 | 2051 | $user_activation_key = empty( $userdata['user_activation_key'] ) ? '' : $userdata['user_activation_key']; |