Hi, I'm launching a new drupal social networking type site. If let's say I am limiting registration to gmail addresses only, is there anyway to automatically generate the username for user during registration to everything before the @ sign in their email? I'm pretty sure there aren't any modules out there for this, are there? Anyone know an easy way to accomplish this? I'm guessing some kind of edit to the core code, so maybe it's not a good idea, but it'd be really helpful in limiting users from creating stupid usernames without listing out a thousand banned words etc... Thanks for your ideas.

Comments

nevets’s picture

You could write a module that does that, no need to modify core.

The module would probably need to implement hook_form_alter to replace the existing user name input with a form 'value' field and hook_user ($op == 'submit') to generate the correct value for the user name from the email.

If you are limiting the email addresses (to gmail for example) you could also use hook_user and $op == 'validate' to validate/limit the email addresses.

Note if you do not limit the email addresses to a single domain and generate the user name from the email address you could possible have duplicate user names.

igdrupal’s picture

Good point about limiting to one domain...I'm pretty clueless when it comes to writing code, but I'll try to have a friend write it soon... perhaps just one that makes the email address into username would be best, tho usernames would be a bit long. thanks again