ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Retrieving username on member login with email

May 27, 2013 1:39pm

Subscribe [2]
  • #1 / May 27, 2013 1:39pm

    David Rousseau

    39 posts

    Good afternoon everyone.

    OK, I have a site where the people register for a yearly membership, and they do receive a real card by mail with a 9 digits card numbers.

    I’ve created a script that assigns a random and unique card number upon registration, and I’ve used that as username.  This way made sense so that people could login to their profile using their card number (like air miles 😉

    Problem is some people forget their card number, so they use the forgot my card number form (which is the forgot my username one).

    BUT, I would like people to be able to use either their card number (username) OR email to login.

    What hook should I look into so that I can :

    1. Check to see if the username requested exists
    2. If not, look for it in the emails of the members in the database
    3. Retrieve the username associated with that email
    4. Use that username for the login script

    I’m using the exp:member:login_form function.

    Thanks for your help

  • #2 / May 27, 2013 1:46pm

    David Rousseau

    39 posts

    Just found “NSM Email Login” on Devot:ee… any comments on the unsanitized user-submitted email address ?

  • #3 / May 27, 2013 4:47pm

    David Rousseau

    39 posts

    Good afternoon, used the NSM Email Login and did a quick adjustment to it, adding some cleaning prior to query the database:

    // Sanitize username prior to query
    filter_var($username, FILTER_SANITIZE_EMAIL);
       
    // Select the username from the members table trying to match it to email
    $query = $EE->db->select('username')

    Working nicely!  Exactly what I needed!

    http://devot-ee.com/add-ons/nsm-email-login

  • #4 / May 28, 2013 12:34am

    Bhashkar Yadav

    727 posts

    Hi David,

    Thanks for sharing it. It may be useful for someone looking for the same.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases