Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Autogenerate or remove username


peterverkooijen
Participant

@peterverkooijen

To autogenerate a temporary username put this function in bp-custom.php:

function randomusername() {
$length = 10; //length of string
$start = 65; //Where to start from on ascii table
$end = 90; //where to end on the table

for ($k = 0; $k < $length; $k++){
$randomname .= strtolower(chr(round(rand($start, $end))));
}

return $randomname;

}

Make this edit to the username input field on the form (hacking core file, should become easier in version 1.1):

<input name="user_name" type="text" id="user_name" value="'.$user_name = randomusername().'" maxlength="50" />

Test it if you want; you’ll see a random string in the username field that will be replace by the autogenerated username based on fullname on activation.

You can hide the username field on the signup form, without getting error messages for not giving it proper TLC, by using this CSS trick.

That requires another core file hack, since you need to add a id like username-form-field. Again, should become easier in version 1.1.

My registration form is now:

Name:

Email address:

And that’s it! Everything works. Full name is available as first and/or last name. The URL is the full name lower case without spaces. :-)

Only thing left to do is clean up the email messages etc. that still mention the username…

Skip to toolbar