mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Users: Add 'illegal_user_logins' filter to allow certain usernames to be blacklisted.
Props danielbachhuber, chriscct7, crazycoolcam, SergeyBiryukov. Fixes #27317. git-svn-id: https://develop.svn.wordpress.org/trunk@35189 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1315,6 +1315,17 @@ function wp_insert_user( $userdata ) {
|
||||
return new WP_Error( 'existing_user_login', __( 'Sorry, that username already exists!' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the list of blacklisted usernames.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param array $usernames Array of blacklisted usernames.
|
||||
*/
|
||||
if ( in_array( $user_login, apply_filters( 'illegal_user_logins', array() ) ) ) {
|
||||
return new WP_Error( 'illegal_user_login', __( 'Sorry, that username is not allowed.' ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* If a nicename is provided, remove unsafe user characters before using it.
|
||||
* Otherwise build a nicename from the user_login.
|
||||
|
||||
Reference in New Issue
Block a user