WebLoginPE lets users log in with their username + password. I want to allow them to log in with either their username + password or their email address + password. Has anyone else done this? Any tips on how this might be achieved?
It seems like it would be easy to change the caption to "Username or Email" and then modify the code to look the user up by email if there was an @ sign in the response.
Quote from: twz at Jun 08, 2010, 02:21 AM
Thanks for the reply BobRay. There’s a slight complication in that some people have used their email address as their username too (so some usernames have @ in them). I realise I probably need to modify the Login function in webloginpe.class.php but the question is how? That function does stuff I don’t really understand.
Maybe the easiest way is to add some code near the top of the function:
- Check if the value entered is an existing username
- If yes, continue as normal
- If not, see if it’s an existing email address - if it is, look up the corresponding username and use that for the rest of the function.
Does that make any sense?
It sounds like a really good solution to me.
BTW, you might want to duplicate and rename the snippet (e.g. MyWeblginPE) so that it can’t be overwritten during an upgrade.
That’s probably what I’ll end up doing then (when I can get to it). I was hoping it could be done without modifying the source code, but I guess not.