$sanitizer->username()
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.
However, when adding a user manually in PW, the name field shows a different formatting requirement:
So inputting email@domain.com into that field automatically changes it to email-domain.com. (The "." does in fact stay in there although its not part of the defined character requirement. No biggie.)Any combination of letters (a-z), numbers (0-9), dashes or underscores (no spaces).
Shouldn't those two formats match?
Background info: The reason this came up is because I'm allowing folks to signup for my parish's website to access parishioner-only content on the site. However, instead of usernames, I'm relying on email addresses for registering and logging in (at least from their point of view). Since each user in PW requires a username, I'm making their username a sanitized version of their email address and was going to use the $sanitizer->username() function to automatically create their username based on their email address. But given the current sanitizing convention of $sanitizer->username(), I'll have to create a new sanitation function to accommodate.
Is there a reason for the discrepancy that I may have overlooked?













