LemonStand Documentation

cms:onGetCustomerGroupId event

The cms:onGetCustomerGroupId event allows to override the Cms_Controller::get_customer_group_id() method result, effectively changing the current customer group on the front-end and thus possibly affecting product prices and pages visibility. The event handler should accept a single parameter - the controller object (Cms_Controller class instance). The handler function should return a customer group identifier or nothing if changing the current customer group is not needed.

Event handler example:

public function subscribeEvents()
{
  Backend::$events->addEvent('cms:onGetCustomerGroupId', $this, 'get_customer_group_id');
}

public function get_customer_group_id($controller)
{
  // Do not override the customer group for logged in customers
  if ($controller && $controller->customer)
    return $controller->customer->customer_group_id;
        
  // Replace the "guest" customer group with some other group
  return 10;
}

Next: cms:onBeforeRoute event
Previous: cms:onPageNotFound
Return to Handling LemonStand events