zend-frameworkmenuauthorizationsocialengine

How to set Navigation menu based on User type - SOCIALENGINE


How to set Navigation based on user type/profile type logged in.

All I could do is - set auth for specific user type

if (!$this->_helper->requireAuth()->setAuthParams('<module>', null, 'create')->isValid())
        return;

But with this the menu will be still available For example - If a Candidate logs in I should be able to hide create JOB menu.

Please give some insights on this. Thanks for your time!


Solution

  • Please create a function in menu.php in plugin of your module.You can check user module and also add a entry 'engine4_core_menuitems'. In table find your menu add entry in plugin _Plugin_Menus. Below function will have naming convention as your your function Name.

      public function onMenuInitialize_JobMenu()
    {
         $viewer = Engine_Api::_()->user()->getViewer();
    
          //assuming level id 4 for candidate
    if( !$viewer->level_id == '4') {
      return false;
    }
    
    return array(
      'label' => 'create Job',
      'route' => 'job_general',
      'params' => array(
        'action' => 'groupsms'
    )
    );
    

    }