Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Why doesn’t BuddyPress support uppercase or underscore in usernames?


sicksight
Participant

@sicksight

Hi! ;)

Does anyone have a solution for this problem? Is it possible to be allowed in capital letters in usernames? All the Links on Google and buddypress.org doesn´t help…

I have tryed out a few things… For example, I’ve replaced in the bp-core-signup.php on line 321
preg_match( "/[a-z0-9]+/", $user_name, $maybe );
with
preg_match( "/[a-zA-Z0-9öäüÖÄÜß]+/", $user_name, $maybe );

In line 327 an error message is generated when the user name does not comply with certain criteria.

if ( !validate_username( $user_name, $strict = false ) || in_array( $user_name, (array)$illegal_names ) || $user_name != $maybe[0] )
$errors->add( 'user_name', __( 'Only lowercase letters and numbers allowed', 'buddypress' ) );

When I comment out followed code in Line 327:
!validate_username( $user_name, $strict = false ) ||
my preg_match rule works with the capital letters and special characters, but I think that will later have an impact on the log on and other things.
Capital letters are now being accepted, but no special characters such as “ßöüÖ” … -.-

validate_username() is a WordPress function
https://codex.wordpress.org/Function_Reference/validate_username
and it uses
sanitize_user() which is documented here:
https://codex.wordpress.org/Function_Reference/sanitize_user

Has anyone any idea how to do this without an sql injection or incompatible usernames later? ;)
I would have liked that a user can log in as “SteffanieKönig” …

When we get together at a solution I would like to summarize the whole issue and as a plugin, but I’m at the end of my knowledge! -.-

SickSight

Skip to toolbar