username_hide module - a simple way to remove username and just use email addresses for accounts

so the NHL folks wanted to only have an email address field in registration. i didn't want to hack up core so came up with this super simple module that hides the username field on the register page and then behind the scenes assigns the username value to whatever the email address is set to.

a couple of key points:

1) the .install file has to set the module weight to -10 in order to make the hook_user() fire before the standard user module fires. this is required since otherwise the user.module will error out since the username will be empty at that point. by calling ours first, we ensure we can set $edit['name'] to $edit['mail'] *before* user.module does its validation.

2) since we hook into validation, the username should be automatically updated should the user change their email address.

3) to avoid unusual issues, you should make sure you don't have any other accounts that don't have the same value for user name and user mail.

4) this does support the profile.module's moving of the core user data into a $form['account'] group. if you have other custom modules that toy with the user form, all bets are off and you'll likely need to hack this as well.

Comments

bug fix for beta2

this has been updated to a new beta2 version which fixes a bug when you have profile module enabled, but have not yet added any other profile groups. i've removed the beta1 version and added the beta2 version above.