By ressa on
I am removing some tabs with a custom module, so that normal users can't see or access them, with this function:
<?php
/**
* Implementation of hook_menu_alter().
* Remember to clear the menu cache after adding/editing this function.
*/
function MODULENAME_menu_alter(&$items) {
// Removing certain local navigation tabs that are either undesired or need to be custom relocated.
// Set these tabs to MENU_CALLBACK, so they still register the path, but just don't show the tab:
$items['node/%node/track']['type'] = MENU_CALLBACK;
$items['user/%user/track']['type'] = MENU_CALLBACK;
$items['search/user']['type'] = MENU_CALLBACK;
// Fully unset these tabs and their paths, don't want them at all. This breaks the path as well:
unset($items['user/%user/example']);
}
?>From here: Remove tabs using hook_menu_alter -- http://drupal.org/node/483324
Does anyone know how to remove the tabs, while allowing admin to both view and access them?
I will update my comment at the Theme snippets page and post the solution, if someone knows how to do it.
Thanks.
Comments
Change the security settings
This task boils down to a permissions issue. I'd change the
access callbackandaccess argumentsattributes in yourhook_menu_alterimplementation to restrict access to only admins.I couldn't figure it out
Hi Cliff,
I looked into it and couldn't figure out how to make it work, but thanks for the tip.
A few steps to accomplish
A few steps to accomplish this. All code goes into your custom .module file:
First, set up a new permission for your module. Then you can go into admin -> user management -> permissions and give this permission to your admins.
Then you need to change the settings for the menu items so that they are only available to users with the permission:
- Ryan
That worked perfectly
Thank you both!
The function now hides view, edit, and track user tabs, while admin has full access.
To avoid double posting more than already, the working code can be found here: Remove tabs using hook_menu_alter
Hello, I just tried to
Hello,
I just tried to implement this code into my drupal site. I have so far managed to get rid of the tabs. However, what I originally wanted to do was to allow registered users to use these tabs through a dropdown menu. The way I wanted to do was to insert the URL in a custom primary link menu block. So far, this is not working. So, I wanted to know if there was a way to get past this problem.
Thanks,
T
More info needed
Hi T!
Can you please post the code you're using, more information, and/or a link to your site so we can see whats going on? Its not immediately clear to me why this isn't working for you - what you're describing sounds very similar to what I had to accomplish for a site on the other thread you commented on (http://drupal.org/node/604850).
How are you populating your menu block - through a module or via the drupal interface?
- Ryan
Hello Ryan, Sure. My website
Hello Ryan,
Sure. My website is www.lateguide.com. If you register, you will able to see the actual menu bar at the top. I disabled the primary and secondary tabs as this was the easiest solution for me. What is left to do for me now is to enter the internal paths to enable some of the links in the "profile" primary link. So, there is no code to enter but just tghe correct URLSs to populate the menu block via the drupal interface.
Thanks for the reply.
Tafa
remove tabs after role submiting
how to remove tabs , After applying some role
Step 1) read this thread.
Step 1) read this thread.
Contact me to contract me for D7 -> D10/11 migrations.