Skip to main content
They are not views permissions, nor should they be used instead of hook_menu_alter().
Source Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

( @kiamlaluno sugguested me to use with views permissions instead of hook_menu_alter)
There There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

( @kiamlaluno sugguested me to use with views permissions instead of hook_menu_alter)
There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

added 2 characters in body
Source Link
learner123
  • 511
  • 6
  • 21

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

(some users @kiamlaluno sugguested me to use with views permissions instead of hook_menu_alter)
There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

(some users sugguested me to use with views permissions instead of hook_menu_alter)
There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

( @kiamlaluno sugguested me to use with views permissions instead of hook_menu_alter)
There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

deleted 7 characters in body
Source Link
learner123
  • 511
  • 6
  • 21

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

There(some users sugguested me to use with views permissions instead of hook_menu_alter)
There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) { global $user; if (in_array('gerant', array_values($user->roles))) { $items['user/%user/infos']['type'] = MENU_CALLBACK; } } 
  1. This doesn't hide the tab, but it works for other tabs -created by other modules- like user/%user/contact.
  2. I wanted this user still be able to see this tab in other users profile.

To add more information

(some users sugguested me to use with views permissions instead of hook_menu_alter)
There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

deleted 7 characters in body
Source Link
learner123
  • 511
  • 6
  • 21
Loading
added information added from the OP in a comment
Source Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284
Loading
edited tags
Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284
Loading
Source Link
learner123
  • 511
  • 6
  • 21
Loading