Use Full Email Address as username

Discussion in 'Customization & add-ons' started by gtms, Oct 28, 2016.

Thread Status:
Not open for further replies.
  1. gtms

    gtms New Member

    Joined:
    Sep 28, 2011
    Messages:
    2
    We are using the newest version of Amember and I cannot seem to find anything on this. I know that if you remove the username field it will auto generate a username from everything prior to the @ symbol. This is problematic for us however. I have found many suggestions on editing things to make this work in previous versions. Has anyone successfully done this with version 5?
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    You can use the following code in site.php file to achieve your needs.
    http://www.amember.com/docs/Site.php_file
    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::GET_LOGIN_REGEX, function(Am_Event $e) {
        
    $e->setReturn('/^[-0-9a-zA-Z_@.]+$/D');
    });
    Am_Di::getInstance()->hook->add(Am_Event::GENERATE_LOGIN, function(Am_Event $e) {
        
    $e->setReturn(array($e->getUser()->email));
    });
  3. gtms

    gtms New Member

    Joined:
    Sep 28, 2011
    Messages:
    2
    This is exactly what we were looking for. Thanks!
    paul_taylor likes this.
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    I glad to hear it. You are welcome!
Thread Status:
Not open for further replies.

Share This Page