Skip Navigation

[Resolved] How to hide toolset buttons in wp editor for non-admin users

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

Problem: I would like to hide the Toolset buttons that appear above the main editor. Only admins should see these buttons.

Solution: Use a custom code snippet:

add_filter( 'toolset_editor_add_form_buttons', function(){
  if( current_user_can('administrator') ) {
    return true;
  }
  return false;
});

Relevant Documentation:

This support ticket is created 5 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by Charles 5 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#1270809
Screenshot 2019-06-17 at 8.58.54 PM.jpg

I am trying to hide toolset buttons in wp editor for non-admin users. I can't seem to find any controls in Toolset settings or Access. I do not want to permanently turn it off even for admin but only for certain users who I allow to post. Thank you.

#1270991

Hi, there are some filters I can show you how to use in custom code. I'm not sure what this means:
"I do not want to permanently turn it off even for admin but only for certain users who I allow to post". Are you saying you want to show the buttons only to specific Users? Are these Users all in the same role, or do you want to manage them by User ID, or some other method?

#1271173

Sorry for the confusion. Basically to manage roles. Will be good if can hide them from all non-Administrator roles.

#1271755

Okay we have a custom code snippet you can use to hide the 3 Toolset buttons above the main editor panel
and WYISYWG fieds for all users except Administrators:

add_filter( 'toolset_editor_add_form_buttons', function(){
  if( current_user_can('administrator') ) {
    return true;
  }
  return false;
});
#1271845

Thanks. Do I add this in Toolset Settings -> Custom code snippets?

#1271855
Screen Shot 2019-06-19 at 12.09.21 AM.png

Somehow I cannot see or add anything in the Custom code snippets section. I checked my WP permission /var/www/html/wp-content/, it's 775. It doesn't have the directory "toolset-customizations", so I created one. Rebooted and still not be to access via WP panel.

#1271905

Okay if you can't access the Custom snippets panel, you can place this code in a child themes' functions.php file. The toolset-customizations folder should also be 0755. If you continue to have trouble with that, feel free to create another ticket and we can investigate in more detail.

#1271935

Yes, it works putting in child theme's functions.php. Still not sure why Custom code snippets section cannot load, but it's ok. Thanks!

#1271937

My issue is resolved now. Thank you!