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?

Related posts

1 comment

  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 _.-@]|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.

Comments are closed.