Make WordPress Core


Ignore:
Timestamp:
12/04/2015 11:24:56 PM (9 years ago)
Author:
boonebgorges
Message:

Use 'invalid_username' error code when tripping 'illegal_user_logins'.

This gives us better compatibility with existing errors thrown by
sanitize_user(), especially in Multisite, where user_login has more
restrictions on allowed characters.

Props markjaquith.
Fixes #27317.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user.php

    r35764 r35772  
    13321332
    13331333    if ( in_array( strtolower( $user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
    1334         return new WP_Error( 'illegal_user_login', __( 'Sorry, that username is not allowed.' ) );
     1334        return new WP_Error( 'invalid_username', __( 'Sorry, that username is not allowed.' ) );
    13351335    }
    13361336
     
    21252125    } elseif ( username_exists( $sanitized_user_login ) ) {
    21262126        $errors->add( 'username_exists', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ) );
     2127
     2128    } else {
     2129        /** This filter is documented in wp-includes/user.php */
     2130        $illegal_user_logins = array_map( 'strtolower', (array) apply_filters( 'illegal_user_logins', array() ) );
     2131        if ( in_array( strtolower( $sanitized_user_login ), $illegal_user_logins ) ) {
     2132            $errors->add( 'invalid_username', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) );
     2133        }
    21272134    }
    21282135
Note: See TracChangeset for help on using the changeset viewer.