4

Any suggestions for a not-too-hacky way to hide the whole CiviCRM top navigation menu for users who don't have a particular permission? I could load some menu-hiding css or js conditional on permissions, maybe in Civi pageRun+buildForm hooks or Drupal preprocess_page hook - but that feels hacky.

CiviCRM 4.6, Drupal 7.

2

There's a CiviCRM navigation hook that you could use in an extension but...

To me this is the wrong approach. Hiding the menu does not stop users from accessing those pages or using the API via JavaScript.

  • Thanks, I know that hiding a menu isn't a substitute for access control! However the requirement from the client is to hide the menu, in order to provide a simplified user interface for (un)certain users. – davejenx Apr 6 '16 at 9:36
1

Can this be done with Drupal user permissions (/admin/people/permissions) and roles? Our organization has a few staff users with varying levels of access; the "CiviCRM: access CiviCRM" permission is what gives users access to the top menu and the API, AFAIK. I've only given that permission to staffers who need full access, and i built custom menu blocks to give partial functionality to other staffers.

So, I have a Member Relations ACL role that has the "Access CiviCRM" permission, and then other ACL roles that don't have that but are enabled on some subcomponents. We're Drupal 7/Civi 4.7.4 right now and this approach has been working for us since 4.4.x. The permissions for Civi are pretty granular and there may be a way to accomplish what you need without writing module code.

1

I know this is an older post but I was looking to do something very similar and it took me a while to figure it out - so I'm sharing in case someone else finds it useful.

I did use the hook_civicrm_navigationMenu. But most of the documentation surrounded how to add something, not remove it. I used the unset function (just like it is used in the hook_civicrm_tabset). The only tricky part is adding the right references to hide the correct menu. For me, I wanted to hide the Mailings menu for 'uncertain' users as @davejenx describes them.

// identify id of Mailings menu in $params array    
$mailingsmenuID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Mailings', 'id', 'label');
// remove the menu
unset($params[$mailingsmenuID]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.