sanitize_user()
Sanitizes a username, stripping out unsafe characters.
Removes tags, octets, entities, and if strict is enabled, will only keep alphanumeric, _, space, ., -, @. After sanitizing, it passes the username, raw username (the username in the parameter), and the value of $strict as parameters for the sanitize_user filter.
Used By: validate_username()
Hooks from the function
Return
String
. The sanitized username, after passing through filters.
Usage
sanitize_user( $username, $strict );
- $username(string) (required)
- The username to be sanitized.
- $strict(true|false)
- If set limits $username to specific characters.
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. |