Assign a usergroup when customers orders a product
Add this code to site.php file:
Am_Di::getInstance()->hook->add(Am_Event::SUBSCRIPTION_CHANGED, function (Am_Event_SubscriptionChanged $event){
// configuration
$products = array(3,4,5); // product# that will trigger group addition
$group_id = 11; // user group# that will be added on purchase of products
// the action
$user = $event->getUser();
if (array_intersect($products, $user->getActiveProductIds())) // if user has subscription to one of $products
{
$groups = $user->getGroups();
if (!in_array($group_id, $groups))
{
$groups[] = $group_id;
$user->setGroups($groups);
}
} else {
// uncomment the following 6 lines (delete //) to REMOVE usergroup when subscription expires
//$groups = $user->getGroups();
//if (in_array($group_id, $groups))
//{
// array_remove_value($groups, $group_id);
// $user->setGroups($groups);
//}
}
});
###: Change URL for signup link on Login Page In order to do it, add this code to site.php file:
Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER, function (Am_Event $e) {
if (stripos($e->getTemplateName(), '/login.phtml') !== false) {
$e->getView()->signup_url = '/your/custom/url';
}
});