Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By renguer0 on
I want to hide simplenews, activity and submissions tabs on user pages. I see that was a module to do that (Tab Tamer) but it was designed to Drupal 7 and I'm in D8.
I tried various alters form codes in module without sucess. Any kind of help was very appreciated.
Comments
You can acomplish this with
You can acomplish this with the following hooks:
hook_menu_local_tasks_alter(),
hook_local_tasks_alter().
For instance, you can remove the 'Edit' tab like this:
I see that but do you know
I see that but do you know how to see the name of other tabs that I've mentioned in order to hide them?
Thanks!
I prefer to explore variables
I prefer to explore variables using kint() (the 'Devel' module is needed).
For instance:
Sorry but I didn't used any
Sorry but I didn't used any debug before. I installed this module and enabled it.
Where I can put this command?
Thanks for your time.
In your case you need to
In your case you need to explore the structure of '$data['tabs']' array.
Therefore put it inside the hook I wrote above, like this:
or like this:
(Also sometimes is useful to insert 'die' after kint(), to stop a script running).
For more details see 'How to Print Variables using Kint in Drupal 8'.
Oh yeah! That's I was looking
Oh yeah! That's I was looking for. To also contribute some from my side, I attach the code for everyone that will looking for:
This code hides Revisions (in nodes), Submissions, Activity and Suscriptions tabs (in user page). Of course, this must be placed in MODULE.module file and MODULE needs to be changed to the module that executes this function.
Thanks for the explanation wombatbuddy, I really searched before and I didn't find this info so clearly.
Yes, It worked for me
Yes, It worked for me.
Thanks!
I know this is an older post,
I know this is an older post, but I'm trying to do this as well without any luck.
I have made a custom module called 'tabedit' made up of only two files: tabedit.info.yml and tabedit.module.php.
tabedit.info.yml
tabedit.module.php
this is just for a test to see if I can remove the Simplenews 'Newsletters' tab. I would also like to get rid of 'Shortcuts', 'Activity', and 'Submissions'. I have tried all the suggestions but nothing seems to be able to remove the tabs. I'd love to find out just what I'm missing.
@wxman, try to rename the
@wxman, try to rename the 'tabedit.module.php' file to the 'tabedit.module'
@wombatbuddy, That was a big
@wombatbuddy, That was a big help! I got rid of the .php and tried this:
That removed the Activity, and Newsletter Subscriptions tabs. Now if I could just find the address of the 'Shortcuts', 'Activity', and 'Submissions' tabs I'd be golden. Thanks for the suggestion.
@wxman, here is the
@wxman, here is the implementation:
But take a note, that hiding of the tabs does not prevent a user from visiting pages. For instance, if a user enter the path like this:
/user/2/simplenews
then he be able to open the ''Newsletters" page.
@wombatbuddy, Thanks again,
@wombatbuddy, Thanks again, that did the trick. I was looking everywhere to find how to address those tabs but wasn't having any luck.
route ldap_authentication.show_user_help_link not hidding
Hi,
I am trying to hide ldap help redirect page but hook menu alter doesn't hide that for authenticated users. Right now logged in users can see log in help tab which doesn't makes sense. Can someone please help?
drupal version 9.2.10
Thanks
@alpha-1 if you share the
@alpha-1 if you share the step to reproduce this case we will try to help.
thanks for replying.
thanks for replying.
I am using ldap module for drupal 9 and under 'LDAP Authentication settings' it has a field LDAP Account User Help URL (URL to LDAP user help/documentation for users resetting passwords etc. Should be of form http://domain.com/. Could be the institutions LDAP password support page or a page within this Drupal site that is available to anonymous users.)
Now this page is showing in tabs on /user/username page for all the logged in users, I have tried above codes with current role 'authenticated' as well, clear cache but it didn't work. It works for shortcut, edit tabs
/**
thank you so much, it works
thank you so much, it works as expected!