sanitize_user()
Cleans the username (login, username) by removing unsafe characters.
Removes: html tags, notes, html entities, and other characters not included in ASCII.
Used By: validate_username()
Hooks from the function
Returns
String. Cleaned username.
Usage
sanitize_user( $username, $strict );
- $username(string) (required)
- The username to be cleaned.
- $strict(boolean)
- If set to true, non-standard characters in the name will be removed. Only characters^
a-z 0-9 _ . - @will be allowed in names. Note that only the English alphabet is available.
Default: false
Examples
#1 An example of how the user name filtering function works:
$string = ' Leonid-{?}[]<tag>rus_yo`@';
echo sanitize_user( $string ); //> Leonid-{?}[]rus_yo`@
echo sanitize_user( $string, 1 ); //> Leonid-_
Changelog
| Since 2.0.0 | Introduced. |