The toolset fields and access buttons should really be hidden from non-admins when using a post content field. The buttons only show up when the option to allow media uploads is checked for the cred submission field. It would be nice if there was a checkbox to disable toolset buttons.
This is partially true and I already filed this exact request a while ago.
Our Buttons should not rely on the insert media capability.
However, it's wrong to assume that non-administrators should not see those.
Everyone who can create and edit posts should see them as they are a substantial part of the building part.
However I as well filed requests to fine tune this control (simply add a capability around those buttons, that you can manage in Access later, it's not a big magic actually, but a question of decisions that I cannot make myself).
Now, for now, you need either to use Custom Roles or Custom Code to fine tune the control
There should be several possible solutions, one for backend the other for front end.
1. Toolset buttons (Fields and Views, CRED, Access) are visible on front-end editors for users with role author+ and when the insert media option is enabled.
You can disable it with the following code:
/**
* Remove Toolset buttons on front-end editors
* which appear for role author+ when the insert
* media option set on CRED forms
*
* The filters work globally, so you will need
* to add a test, e.g. for the page where the
* CRED form is added
*/
function remove_toolset_buttons(){
// $post not available with init hook
$postID = url_to_postid( $_SERVER['REQUEST_URI'] , '_wpg_def_keyword', true );
$target_pages = array( 10, 25, 66 ); // Edit for pages with CRED forms
if ( in_array( $postID, $target_pages ) ) {
// 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(){
$roles = array( 'author', 'subscriber' );
return $roles;
} );
}
}
add_action( 'init', 'remove_toolset_buttons' );
2. 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.
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 an example, you can replace those with your roles as needed. These are in the if conditional statement.
Then, download & extract this file, and place this CSS file in the wp-content/themes/your_theme/ (inside your theme) folder in your site:
hidden link