sanitize_user( string $username, bool $strict = false )
Sanitizes a username, stripping out unsafe characters.
Description
Removes tags, percent-encoded characters, HTML 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.
Parameters
- $username
-
(Required) The username to be sanitized.
- $strict
-
(Optional) If set to true, limits $username to specific characters.<br>
Default value: false
Return
(string) The sanitized username, after passing through filters.
Source
File: wp-includes/formatting.php
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |