This code allows you to Remove buttons (fields and views, Content Layout Editor, CRED form, Access, Bootstrap buttons) from backend WP editor for certain user roles.
Solution:
1. Add this code in your theme’s or child theme’s functions.php file:
add_filter( 'mce_buttons_3', 'remove_bootstrap_buttons', 999 );
function remove_bootstrap_buttons($buttons) {
if( current_user_can('editor') || current_user_can('contributor') ) {
return array();
}
else {
return $buttons;
}
}
add_filter( 'mce_buttons', 'remove_toggle_button', 999 );
function remove_toggle_button($buttons) {
if( current_user_can('editor') || current_user_can('contributor') ) {
$remove = array( 'css_components_toolbar_toggle' );
return array_diff( $buttons, $remove );
}
else {
return $buttons;
}
}
function vm_wptypes_remove() {
if( current_user_can('editor') || current_user_can('contributor') ) {
wp_enqueue_style( 'wp-types-special', get_stylesheet_directory_uri() . '/wp-types-special.css' );
}
}
add_action( 'admin_init', 'vm_wptypes_remove' );
==> In above code, I have used ‘editor’ and ‘contributor’ level roles as example, you can replace those with your roles as needed. These are in the if conditional statement.
2. Download & extract this file >> and place this css file in the folder in your site:
wp-content/themes/et/ (inside your theme folder)
CSS file:
https://drive.google.com/file/d/0B5EmJQ1qcuyqTU4xZ3paM01ERmc/view?usp=sharing
Related tickets:
https://wp-types.com/forums/topic/removing-buttons-for-certain-user-roles-for-the-post-editor/
https://wp-types.com/forums/topic/how-to-remove-fields-and-views-button-above-post-edit-for-non-admin-users/