Forums / Developer / No username required for user account use email only

No username required for user account use email only

Author Message

Nathan Kelly

Thursday 01 March 2007 8:16:46 pm

Hi all,

I've had a request from a client to remove the username from user accounts and registration so that users don't have to come up with a unique username. They would prefer that the user sign in with an email address as their username instead.

I know I can allow users to sign with their email but they still need to create a unique username at registration time, we have had many users complaining that it takes them more than on attempt to sign up due to the username having to be unique a common comment is "my name is John why can't I use John as my username (this place sux)?"

Not really the kind of feedback the client wanted...

There is a setting for unique email in site.ini but nothing for unique username, which would be really handy right now.

[UserSettings]
AuthenticateMatch=login;email
RequireUniqueEmail=true

the AuthenicateMatch also didn't seem to make any difference when I changed it to email only (other than the fact that it crashed the site).

I've been looking for a solution to this but so far haven't found one that doesn't involve hacking the kernel, which I would like to avoid at all costs. (http://ez.no/community/forum/developer/users_without_login)

Is there a way to allow users to sign up without having to enter a username?

Any help is appreciated, I'm copping a lot of flack from the client at the moment and I really need to find a solution as quickly as possible.

Cheers.

Pardon me while I burst into flames...

Bruce Morrison

Thursday 01 March 2007 8:44:57 pm

Hi Nathan

No real quick fix for this. What you can do without hacking the kernel is hide the username form element in the signup and set the value to be the attribute_id ("user"+ attribute_id might be better esp. if there is a length limit on usernames)

standard/templates/content/datatype/edit/ezuser.tpl

...
{* Username. *}
<div class="element">
    {section show=$attribute.content.has_stored_login}
        <input type="hidden" name="{$attribute_base}_data_user_login_{$attribute.id}_stored_login" size="16" value="{$attribute.content.login}" disabled="disabled" />
        <input type="hidden" name="{$attribute_base}_data_user_login_{$attribute.id}" value="{$attribute.content.login}" />
    {section-else}
        <input id="ezcoa-{if ne( $attribute_base, 'ContentObjectAttribute' )}{$attribute_base}-{/if}{$attribute.contentclassattribute_id}_{$attribute.contentclass_attribute_identifier}_login" class="ezcc-{$attribute.object.content_class.identifier} ezcca-{$attribute.object.content_class.identifier}_{$attribute.contentclass_attribute_identifier}" type="hidden" name="{$attribute_base}_data_user_login_{$attribute.id}" size="16" value="user{$attribute.content.id}" />
    {/section}
</div>
...

To do this completly you'd need to override all templates that use the username and hide/remove it.

Hope this helps.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Nathan Kelly

Thursday 01 March 2007 8:59:33 pm

Thanks Bruce,

I actually had this in mind and I started to test it out, I think is the cleanest fix for my problem at this stage because it only involves overriding templates as opposed to hacking.

I'm assuming I'll need to override the Admin templates too?

Cheers!

Pardon me while I burst into flames...

Nathan Kelly

Thursday 01 March 2007 9:27:18 pm

Works like a charm, but if anyone else is looking at Bruce's example there is one change needed:

Change:
value="user{$attribute.content.id}"
To:
value="user{$attribute.content.contentobject_id}"

Thanks Bruce, you just saved my hide.

Cheers!

Pardon me while I burst into flames...

Bruce Morrison

Thursday 01 March 2007 11:05:21 pm

Hi Nathan

Opps. I had meant to write:

value="user{$attribute.id}"

as

value="user{$attribute.content.contentobject_id}"

Will cause issues if for some reason there are multiple user attributes as part of the one content object (umlikely I know)

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Fabricio Guerrero

Monday 05 March 2007 9:25:23 am

hi...

changing this post just a bit...

i have a request from a client wanting us to remove passwords and only want users to have to register/login with an username.

is their a clean way to go about this? or is this some dirty kernel hacking?

regarding no username... i had a similar request over a year ago from another client and what i did i guess is a bit dirty.. but i made the user field hidden and on the onSubmit method via javascript copied over the email into the user account field(hidden field)..

this way username and email was always the same and easy to remember.

http://www.solobromasychistes.com <<Joomla Site :P
http://www.recipesforhealthyfood.com/ <<Drupal Site :P
http://www.ezforge.com/ <<future ezCommunity, Articles, forums and more...