0

On my user profile I have various tabs (view, my bookmarks, translate, ...). the problem ist, those tabs should only be visible for profile owner and not if I visit another profile.

Some of those tabs (bookmarks, submissions) are set via view: user/%/submissions with a menu tab - the permissions here are set. But how do I set permission for those tabs only to the current user?

0

Alter menu and set 'access callback' => 'user_access' Or if you have custom profile tpl then render tabs like this:

global $user;
if (arg(0) == 'user' && $user->uid == arg(1)){
  //*******render tabs here*********/
}
  • if I set $items['user/%/view']['access callback'] = 'user_access' I can't the see tab, even if I am on my own profile. Also do I have to set this for every single tab? – scar Sep 25 '15 at 12:06
  • /** * Implementing hook_menu_alter * Restrict MENU TABS access */ global $user; function MODULE_NAME_menu_alter(&$items) { if(isset($user) || $user->uid !=0) { $items['user/%user/yourtabname1']['access callback'] = FALSE; $items['user/%user/yourtabname2']['access callback'] = FALSE; //Change the MENU PATH as per your requirement. } } Yes ,you have to set permission for each tab. – Aruna Singh Sep 26 '15 at 3:53

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.