Login with username or email
Permalink 1 user found helpful
Hi,
Currently there is a feature to set login to work with email instead of username. Is there any way to make it so that the user has a choice to login in either with username or email (both can be used)?
Thanks
Currently there is a feature to set login to work with email instead of username. Is there any way to make it so that the user has a choice to login in either with username or email (both can be used)?
Thanks
No luck...
I would also find this useful if anyone has a solution.
Hi,
Go to dashboard/system settings /registration / public_registration /
the last checkbox enable this functionality
Go to dashboard/system settings /registration / public_registration /
the last checkbox enable this functionality
sebastienj, I believe the last option in Public Registration is "Use emails for login", this does not give the user/member the option to login using either username or email address, it allows user/member login with email address only as far as I am aware.
Exactly ! I has not read clearly the question ! :-)
This a bit late for a reply, but I wanted to post this solution in the forums so it's available to people.
For an easy-ish way to allow users to login with their username OR email override the login controller and update the do_login method by replacing this line:
with this...
For an easy-ish way to allow users to login with their username OR email override the login controller and update the do_login method by replacing this line:
$u = new User($this->post('uName'), $this->post('uPassword'));
with this...
$uName = $this->post('uName'); if( USER_REGISTRATION_WITH_EMAIL_ADDRESS && strpos($uName, '@') === false ) { $ui = UserInfo::getByUserName($uName); if( $ui ) $uName = $ui->getUserEmail(); } else if( !USER_REGISTRATION_WITH_EMAIL_ADDRESS && strpos($uName, '@') !== false ) { $ui = UserInfo::getByEmail($uName); if( $ui ) $uName = $ui->getUserName(); } // original line updated to use $uName instead of $this->post('uName'). $u = new User($uName, $this->post('uPassword'));
This doesn't work for me. I get an error on line 498 of login.php which seems to be a closed bracket. As I look at your if statements, I don't really understand the ifs inside other ifs with no brackets, but I am not a PHP master.
In any case, copying and pasting as you said creates an error for me.
In any case, copying and pasting as you said creates an error for me.
If your error is on a closing bracket, it's likely that you have an extra closing bracket (or missing an opening bracket). Try reverting and copying and pasting again. I double checked and this is the same as what I have.
Okay, anyway, this is the error I was getting...
Fatal error: Cannot redeclare class Concrete5_Controller_Login in /Applications/MAMP/htdocs/c5test/single_pages/login.php on line 501
...and I guess I just wasn't overriding it correctly or something.
I updated the line on the original core file and it worked... well, it didn't work, really, but it didn't give an error. I still only see the option to login using email address, but it's likely something to do with my setup, I guess. I checked "register by email" in the dashboard, so apparently that's the only option I can get no matter what.
Fatal error: Cannot redeclare class Concrete5_Controller_Login in /Applications/MAMP/htdocs/c5test/single_pages/login.php on line 501
...and I guess I just wasn't overriding it correctly or something.
I updated the line on the original core file and it worked... well, it didn't work, really, but it didn't give an error. I still only see the option to login using email address, but it's likely something to do with my setup, I guess. I checked "register by email" in the dashboard, so apparently that's the only option I can get no matter what.
Thanks