Enable Helpdesk access only for users with a specific product
Add this code to site.php file:
function isHelpdeskEnabledForCurrentUser(){ $user = Am_Di::getInstance()->auth->getUser(); if (!$user) { return true; // Give the user a chance to log in first }
foreach ($user->getActiveProducts() as $product) { if ($product->data()->get('helpdesk_enabled')) { return true; } }
return false;}
Am_Di::getInstance()->productTable->customFields()->add( new Am_CustomFieldSelect( 'helpdesk_enabled', 'Enable access to Helpdesk', '', '', ['options' => [0 => 'No', 1 => 'Yes']] ));
Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, function (Am_Event $event) { $menu = $event->getMenu(); if (!isHelpdeskEnabledForCurrentUser() && ($page = $menu->findOneById('helpdesk'))) { $page->getParent()->removePage($page); }});
Am_Di::getInstance()->hook->add(Am_Event::INIT_CONTROLLER_PAGES, function (Am_Event $event) { $controller = $event->getController(); if (!($controller instanceof Helpdesk_IndexController)) { return; }
if (!isHelpdeskEnabledForCurrentUser()) { throw new Am_Exception_InputError(___('Access denied!')); }});By default, Helpdesk access is disabled for all users. To enable it for a
product, edit that product in aMember CP -> Manage Products and set
Enable access to Helpdesk to Yes in the Additional section.
Copyright © 2002–2026 www.amember.com. All Rights Reserved.