Email as Username Help

Discussion in 'Customization & add-ons' started by goldseal, Sep 3, 2009.

  1. goldseal

    goldseal New Member

    Joined:
    Aug 31, 2009
    Messages:
    4
    So far I'm loving amember.

    I've gone through the changes found in this forum to allow the username to be an email address, but need to modify it slightly to allow a period in the email address as when someone tries to register with an email address like firstname.lastname@server.com it tells them there is an invalid character in their username.

    I'm just assuming it's the period it's complaining about.

    The changes I made are here: http://www.amember.com/forum/showthread.php?t=7480&highlight=email username&page=2

    I think I might need to modify the getLoginRegex which I assume is the validation of the username???? I am really terrible at regular expressions, so can anyone help me out with what changes I might need to make?

    Thanks!

    goldseal
  2. goldseal

    goldseal New Member

    Joined:
    Aug 31, 2009
    Messages:
    4
    actually, it could be a dash too after the @ that could be the invalid character.

    I just don't know enough about regular expressions to correct it.

    Any regular expression guru's out there?
  3. goldseal

    goldseal New Member

    Joined:
    Aug 31, 2009
    Messages:
    4
    I've figured it out.

    I just added a /- after each part of the regular expression and that seemed to fix it.

    PM me if anyone wants the exact code.
  4. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    @goldseal,

    what version of aMember are you using?

    I'd love to see a copy of the final regular expression code (and specifically which file you changed).. sadly no PM so I'm posting my request here :)
  5. AQUARiUSQ

    AQUARiUSQ New Member

    Joined:
    Oct 29, 2009
    Messages:
    3
    Complete regular expression for getLoginRegex

    Does anyone have the complete regular expression for getLoginRegex that allows for email addressen containing ".", and checks for the dash after the "@" sign?

    Thanks in advance!
  6. AQUARiUSQ

    AQUARiUSQ New Member

    Joined:
    Oct 29, 2009
    Messages:
    3
    Andah... the answer!!!

    Never mind. I found a good online regex tester so I was able to answer my own question.
    In case others have the need to accept email adresses for usernames, here's the correct regex:

    Code:
    /^[^\W][a-zA-Z0-9_.]+([a-zA-Z0-9_.]+)*\@[a-zA-Z0-9.]+([a-zA-Z0-9.]+)*\.[a-zA-Z]{2,4}$/
    
    This regex allows for "-" and "." in the mailbox part (the part in front of the '@'), and "." in the domain part (the part after the '@').

    FrostyX
  7. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    yeah, it's just the regex that throws some of these emails out as unacceptable.

    maybe I should post the one I found worked wonders with some of the weird emails that people were trying to sign up with and the one above would choke on...

    try this too:

    Code:
    /^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/

Share This Page