Skip Navigation

[Resolved] Split: Can’t hide toolset in dashboard menu – hide it for custom roles

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to hide the Toolset menu in admin (backend) for a specific role

Solution:
To hide/remove Toolset menu for a specific user role, you need to use the standard WordPress hook: admin_menu

You can find the proposed solution, in this case with the following reply:
=> https://toolset.com/forums/topic/split-cant-hide-toolset-in-dashboard-menu-hide-it-for-custom-roles/#post-1623699

Relevant Documentation:
=> https://developer.wordpress.org/reference/hooks/admin_menu/

This support ticket is created 4 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 17 replies, has 2 voices.

Last updated by zbyszekZ 4 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#1622621

Hi Minesh,
I have the same problem. I would like to hide Toolset from administration sidebar for my custom roles.
I created this role via copy of administrator role.
I added your code in this way => https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
Run it and enabled, but Toolset is still visible in this menu in this custom role user 🙁

Please write me how can I fix it.

Best regards!

#1622627

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please tell me for what custom role you want to hide the Toolset menu?

#1622709
Zrzut ekranu 2020-05-13 o 13.19.23.png

Hi,
Maybe I didn't describe it correctly. My English is not so good, sorry.
I would like to hide "Toolset" link in from administration sidebar.
But only for one custom role.

Like in attachment picture.

Best regards!
Zbyszek

#1622727

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I understand that but for what custom role you want to hide the Toolset menu?

#1622841

My custom role is named "adminklienta"

#1622847

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can add the following code to your current theme's functions.php file or "Custom Code" section offered by Toolset:

// Put the code of your snippet below this comment.
function remove_toolset_menus(){
    global $current_user;
     
    if(in_array('adminklienta',$current_user->roles)) {
        remove_menu_page('toolset-dashboard'); 
    }
}
add_action( 'admin_menu', 'remove_toolset_menus' , PHP_INT_MAX );

I hope the above solution will help you to resolve your issue.

#1622923

Thanks for this advice.
I tried it before, but it didn't help me 🙁
Toolset is still visible in menu.

Maybe this problem is connected with it that 'adminklienta' role is copy from 'admin' role with some modifications?

#1622933

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share access details for the site and tell me for which user you want to hide the Toolset menu.

*** Please make a FULL BACKUP of your database and website.***
I have set the next reply to private which means only you and I have access to it.

#1623699

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now, I logged in using the zz and I do not see the Toolset menu in the backend. Please check the screenshot: hidden link

I've installed and activated Types plugin on your install and added the following code:

// Put the code of your snippet below this comment.
function remove_toolset_menus(){
    global $current_user;
      
    if(in_array('adminklienta',$current_user->roles)) {
        remove_menu_page('toolset-dashboard'); 
    }
}
add_action( 'admin_menu', 'remove_toolset_menus' , PHP_INT_MAX );

If you do not want to install/activate the Types plugin, you should add the above code to the theme's funcitons.php file.

#1624037

Hi Minesh,
Now it works good! Thanks a lot! 🙂
Could you write me where was problem?
What did you fix it?

#1624041

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

as shared with my previous reply:
https://toolset.com/forums/topic/split-cant-hide-toolset-in-dashboard-menu-hide-it-for-custom-roles/#post-1623699

I've installed and activated Types plugin on your install and added the code I shared to "Custom Code" section.
=> hidden link

#1624083

Yes, I read it. But I wonder why Types is necessary if you didn't do anything in this plugin?
I thought that only one needed is Access.

#1624091

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Types plugin required because we added the code to the "Custom Code" section which is offered by Types plugin.

You can move the code to functions.php file if you want and disable the Types plugin.

#1624187

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Please feel free to close the ticket 🙂

#1624193

"Custom Code" section was in only Access, too 🙂
So I understand that this option of Access didn't work without Types?