validate_username( string $username )
Checks whether a username is valid.
Parameters
- $username
-
(Required) Username.
Return
(bool) Whether username given is valid
Source
File: wp-includes/user.php
function validate_username( $username ) {
$sanitized = sanitize_user( $username, true );
$valid = ( $sanitized == $username && ! empty( $sanitized ) );
/**
* Filters whether the provided username is valid or not.
*
* @since WP-2.0.1
*
* @param bool $valid Whether given username is valid.
* @param string $username Username to check.
*/
return apply_filters( 'validate_username', $valid, $username );
}
Changelog
Version | Description |
---|---|
WP-4.4.0 | Empty sanitized usernames are now considered invalid |
WP-2.0.1 | Introduced. |