WordPress User Name Limitations

I need to know what the wp specifications for the usernames are. Like allowed minimum and maximum length, are special characters like ü,ö,ä,ß accepted,..?

Unfortunately I couldn’t find any insight on this in the interweb. Do you have any?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I think the answer is in the source.

$username = wp_strip_all_tags( $username );
$username = remove_accents( $username );
// Kill octets
$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities

// If strict, reduce to ASCII for max portability.
if ( $strict )
     $username = preg_replace( '|[^a-z0-9 _.<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a28fe2">[email protected]</a>]|i', '', $username );

So, the code strips tags, octets, and html entities. And it replaces accented characters with unaccented ones via the remove_accents function, which is fairly lengthy. Other characters get through unless $strict is true (default is false), in which case only ASCII characters are allowed.

The maximum login name length would be the database limit for the user_login column— 60 characters. The minimum, as best I can tell, is 1.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x