Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Buddypress registration: how to use the name to generate the username

@ositive

Participant

Hi aaronthomas1979
Thanks for yuor answer
Absolutely yes! please share your code!
I would like to do something a bit different, but I think that I should start from your code adapting it to my scope.
What I exactly want to achieve: something like facebook do, that is to copy the full name (that is the only name the user will digit in the registration form) in the username (that must be automatically generated). The problem with this solution is that the username must be unique so I could insert a code like the following to insert a number at the end of the name making it unique:

function username( $username){
	$username = $username[0];
	$j = 1;
	while ( username_exists( $username ) ){
		$username = $username . '_' . $j;
		$j++;
	}

	return $username;
}

I think this is the cleanest solution: the users will insert the real name in the registration form, (without asking to change the full name inserted if another user with the same name is already registered) but a unique username is created silently anyway.
Please share, hope to find a solution with yours o any other contribute
Thanks
Ositive

Skip to toolbar