Hi. Forgive the maybe trivial question, but I don't know how to trigger custom PHP code when a user is granted access to a specific product, both manually and after regular payment. I've tried by hooking directly into wordpress API (wordpress' add_user_role) but it doesn't work. Apparently aMember is manipulating wordpress' database directly, bypassing it's hooks. How do I circumvent it? Thanks
Hello, You can use the following code in site.php file: http://www.amember.com/docs/Site.php_file PHP: Am_Di::getInstance()->hook->add(Am_Event::ACCESS_AFTER_INSERT, function(Am_Event $e) { $access = $e->getAccess(); if ($access->product_id == 1) { /* @var $user User */ $user = $access->getUser(); //do some stuff for product with ID 1 }}); Reference: http://www.amember.com/docs/API/HookManager Best Regards.
Thanks Caesar. I've found the solution. The event USER_AFTER_INSERT or USER_AFTER_UPDATE are triggered only upon manipulation of user's profile page. I used SUBSCRIPTION_ADDED instead, and it works, thanks.