Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Last active February 7, 2018 10:26
Show Gist options
  • Save cgi-caesar/9fe6333fa6889ba0ec37d92c381f7fa8 to your computer and use it in GitHub Desktop.
Save cgi-caesar/9fe6333fa6889ba0ec37d92c381f7fa8 to your computer and use it in GitHub Desktop.
aMember (site.php): generate username based on customer full name
<?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