Hello, You can put the following code snippet to site.php file: http://www.amember.com/docs/Site.php_file PHP: Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT, function (Am_Event $e) { /** @var User $user */ $user = $e->getUser(); //execute any code, you can relay on $user (represent record from user table)});
I've tried this, but when a user signs up it echoes a blank line instead of the username: PHP: <?phprequire_once '/var/www/html/members/library/Am/Lite.php';$username=Am_Lite::getInstance()->getUsername();if (!defined('INCLUDED_AMEMBER_CONFIG')) die("Direct access to this location is not allowed");Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT, function (Am_Event $e) { /** @var User $user */ exec("echo '".$username."' >> /tmp/test");});
I do not recommend to use Am_Lite within aMember codebase (this class is designed to access data about logged in user from 3rd party scripts). In your case you need to use $user->login ie.: PHP: Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT, function (Am_Event $e) { /** @var User $user */ $user = $e->getUser(); $arg = escapeshellarg($user->login); exec("echo {$arg} >> /tmp/test");});