How to hide tab for some users

Hello! Happy New year! <3

I wonder, I have a tab in the module, I want to hide this tab for other users and open only one role. Is it possible?

thank you !


OTB no, with custom code however it should be possible.

This thread has no conclusion but maybe a place to start

Otherwise, I’m sure someone will get back to you with some better ideas on what to try!

1 Like

We use this plugin for our client systems

It is the advanced security groups and one feature allows you to create different layouts based on Security Groups / Roles

  • Custom group layouts
  • Login/Sudo as any user
  • Filter search results by groups
  • Create Permissions
  • Quick role grid setup
  • Mass assign/remove from lists
  • Custom module support
  • Multiple group assignments
  • Unlimited users

You can create a custom detailviewdefs file for the module like e.g. for Accounts it would be


and then add some custom code for hiding the TAB for a certain role

if (your condition) {
    //this is for account Information TAB you need to check what you want to remove. 
1 Like

Ok so I had in mind that it would be better for my case to hide the tab for everyone but the Admin security group (This is the name of that security group in my case). This changes things a little bit as I can’t just get the role, which would have been a little bit easier as shown here:

$isEnabledRole = in_array("Privileged", ACLRole::getUserRoleNames($current_user->id));

So I had to make a little function to see if the user is actually part of that security group. I’ve put this function under custom/modules/Leads/views/view.detail.php

 * isOnSecurityGroup
 * Check if the user is on given Security Group. The first argument must be a string with the
 * name of the security group. Second argument will be the array with security groups given
 * from getUserSecurityGroups(). Used on custom/modules/Leads/metadata/detailviewdefs.php
public function isOnSecurityGroup ($security_group_name, $security_group_list) {

        foreach ($security_group_list as $security_group) {
        if (($security_group['name'] === $security_group_name || $security_group['name'] == $security_group_name) || (is_array($security_group) && isOnSecurityGroup($security_group_name, $security_group))) {
                        return True;
        return False;

Very simple function just to check whether or not a given user is part of a security group. Then, as this function is under a class CustomLeadsViewDetail that extends LeadsViewDetail I had to use the following code to use it inside custom/modules/Leads/metadata/detailviewdefs.php

global $current_user; // This is necessary in order to see the id for the current user
$current_security_groups = SecurityGroup::getUserSecurityGroups($current_user->id); // Get current user security groups, gives an array
$isEnabledSecurityGroup = CustomLeadsViewDetail::isOnSecurityGroup("Admin", $current_security_groups); // Here we call our new function

if (!$isEnabledSecurityGroup) {
        unset($viewdefs['Leads']['DetailView']['panels']['lbl_detailview_panel3']); // Unset tab if the user hasn't got the Admin Security Group on his array

I hope this helps someone. Good luck guys.

Edit: Also this code from @cherub-chum helped me on that last part. Just wanted to give you credit for that.


I have detected that this only works when developer mode is enabled which doesn’t use the cache, that’s an issue. I will be working on that and try to update when I find a solution. If anyone knows how to solve it that would be really useful. Thank you guys.

What about using a combination of your code with some javascript? By that I mean adding some function to the page to hide some components based on current user.