Juergen Posted September 1, 2014 Posted September 1, 2014 First of all, its not a big problem. I have created a custom registration form. For the username field I have used the sanatizer api before storing the username in the database. $username is the variable from the form input after submit (Post) I sanatize it like this: $username = $sanitizer->username($username); In the guidelines there is the following statement: Sanitizes a value for a User name, meaning all characters except for these ASCII characters "a-zA-Z0-9-_.@" (not including the quotes) are removed. It also truncates the length to 50 characters. So far so good, but sanatizing the username value changes all big letters [A-Z] to small letters [a-z]. So it doesnt allow big letters in the username. It is not a big deal, but big letters should be allowed according to the statement. Does anyone made the same experience. PS: I use the latest stable version of PW. Addition: it also changes the "@" into "-" .
Martijn Geerts Posted September 1, 2014 Posted September 1, 2014 A User in ProcessWire is actually a Page. The name part of the page is used for the username, this way a user is always unique.
Soma Posted September 1, 2014 Posted September 1, 2014 @deprecated, use pageName instead. This is since 2.4. /** * Format required by ProcessWire user names * * @deprecated, use pageName instead. * @param string $value * @return string * */ public function username($value) { return $this->pageName($value); /* $value = trim($value); if(strlen($value) > 128) $value = substr($value, 0, 128); if(ctype_alnum(str_replace(array('-', '_', '.', '@'), '', $value))) return $value; return preg_replace('/[^-_.@a-zA-Z0-9]/', '_', trim($value)); */ } 1
Juergen Posted September 1, 2014 Author Posted September 1, 2014 Thanks Soma, this was what I am looking for. Unfortunately there was no hint in the explaination of $sanitizer->username($value) that this is dpreceated in 2.4.
Soma Posted September 1, 2014 Posted September 1, 2014 There's no sanitizer username in the docs https://processwire.com/api/variables/sanitizer/ If you mean the cheatsheet.processwire.com yes it's still there, but it's because it's not maintained at the moment.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now