Problem: I would like to hide the Fields and Views, Forms, and Access buttons above WYSIWYG editors in my Forms from all Users except Admins.
Solution: Add the following custom code snippet in your child theme's functions.php file:
// https://toolset.com/forums/topic/hiding-options-in-the-post-form-content-field/ // hide advanced form buttons from non-admins function remove_toolset_buttons(){ global $current_user, $wp_roles; $admin = 'administrator'; // roles that can see the buttons // get non-administrator role slugs if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $all_roles = $wp_roles->get_names(); $editable_roles = apply_filters('editable_roles', $all_roles); $editable_role_names = array(); foreach($editable_roles as $role=>$details) { $editable_role_names[]= $role; } // remove f&v, forms, conditional output buttons if ( !in_array( $admin, $current_user->roles ) ) { add_filter( 'toolset_editor_add_form_buttons', '__return_false' ); add_filter( 'toolset_cred_button_before_print', '__return_false' ); } // remove the Access button add_filter( 'toolset_editor_add_access_button', function() use ($editable_role_names){ return $editable_role_names; }); } add_action( 'init', 'remove_toolset_buttons' );
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)
This topic contains 2 replies, has 2 voices.
Last updated by 3 years, 4 months ago.
Assisted by: Christian Cox.