Skip Navigation

[Resolved] How to disable toolset buttons on post content fields for non-admins?

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

Problem:

The issue here is that the user wanted to disable the toolset buttons on the frontend for specific user roles.

Solution:

Add the following to your functions.php file.

function remove_toolset_buttons(){
  
    $roles = array( 'administrator' ); // roles that can see the button

    $user = wp_get_current_user();
  
    if ( !in_array( $user->roles[0], $roles ) ) {
        // remove the Fields and Views button
        add_filter( 'toolset_editor_add_form_buttons', '__return_false' );
  
        // remove the CRED button
        add_filter( 'toolset_cred_button_before_print', '__return_false' );
  
        
    }
     // remove the Access button for certain roles
        add_filter( 'toolset_editor_add_access_button', function(){
            $roles2 = array( 'author', 'subscriber' );
            return $roles2;
        } );
}
add_action( 'init', 'remove_toolset_buttons' );

Now for the $roles variable this is an array of the users that should see the button.

For $roles2 this is an array of users to disable the button for.

This support ticket is created 6 years, 7 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 15 replies, has 3 voices.

Last updated by Oliver 6 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#854089

Thanks Shane, but this didn't fix it. Still throwing the same error unfortunately.