How do I set email as username in Joomla 3.x?

4.1k views Asked by At

I managed to edit most of the registration form by adding fields to the database and tweaking the xml files and the php files. I even found a free plugin that allows login with an email and not the username.

But I can't figure out a way to remove the username entirely. or at least remove it from the form and creating an automatic username (that the user doesn't even really needs to see ever)

I'm well aware of the Email as Username plugin but hope I can do it without it.

2

There are 2 answers

0
Andrew Eddie On

So this is going to be a bit tricky. Joomla doesn't allow the email to be passed to the authentication plugin so you are going to have to proxy it through the username field.

On the site, I'd create a new login module that simply changed the label of the username field to "Email". You still need to keep the name of the field as username.

Then, in the Joomla Authentication plugin, see https://github.com/joomla/joomla-cms/blob/master/plugins/authentication/joomla/joomla.php#L50

try changing that line to:

->where('email=' . $db->quote($credentials['username']));

Just try that hack for now and see if it works. If it does all you need to do is copy that plugin, with the modification, and rename it to something else (remember to restore the old code in the original plugin). Let me know how you go.

1
joomleb On

it wouldn't have been simpler:

Register

  • hide the username field (CSS)

  • saving (during creation and editing), fill in the username field with the value of that email. (I'm not a developer and cannot help here) Maybe, Do you have an idea / suggestion ?

Login

  • with a simple language override change the "Username" label with "Email" (the same in emails and alerts)