Last active
February 7, 2018 10:26
-
-
Save cgi-caesar/9fe6333fa6889ba0ec37d92c381f7fa8 to your computer and use it in GitHub Desktop.
aMember (site.php): generate username based on customer full name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add(Am_Event::GENERATE_LOGIN, function (Am_Event $e) { | |
$user = $e->getUser(); | |
if ($_ = preg_replace('/[^0-9a-zA-Z]/', '', "{$user->name_f}{$user->name_l}")) { | |
$i = 1; | |
$l = $_; | |
while (!$e->getDi()->userTable->checkUniqLogin($l)) { | |
$l = $_ . $i++; | |
} | |
$e->setReturn(array($l)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment