sanitize_user ( $username, $strict = false )

  • (string) username The username to be sanitized.
  • (bool) strict Optional. If set to true, limits $username to specific characters. Default false.
  • (string) The sanitized username, after passing through filters.
Defined at:


Sanitizes a username, stripping out unsafe characters.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 {@see 'sanitize_user'} filter.

Related Functions

sanitize_url, sanitize_term, sanitize_user_field, sanitize_key, sanitize_user_object

Top Google Results

User discussions

wpseek mobile