Since installation of ToolSet I am seeing extra tabs on my forms for CRED, Access, Fields and Views (See screenshot). These appear even on forms that were created before the install and not built with ToolSet. If I login as a plain user with no admin rights these still appear. Is there a way to turn them off?
Hi,
There isn't such a built-in feature within Toolset plugins, but you can try to disable those Toolset buttons with Toolset filter hooks, for example, you can disable those button for users who is not an administrator or editor, add below codes into your theme/functions.php:
function remove_toolset_buttons(){
$current_user_role = get_current_user_role();
// setup allowed user's role here
$roles = array('administrator', 'editor');
if(
!in_array($current_user_role, $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($current_user_role){
$current_user_role = get_current_user_role();
$roles = array( $current_user_role );
return $roles;
} );
}
}
add_action( 'init', 'remove_toolset_buttons' );
function get_current_user_role() {
if( is_user_logged_in() ) {
$user = wp_get_current_user();
$role = ( array ) $user->roles;
return $role[0];
} else {
return false;
}
}
More help about user role:
https://codex.wordpress.org/Roles_and_Capabilities#Roles
Luo
Unfortunately when I inserted this script I got a server 500 error. I am not a PHP programmer so I am unsure if there is a bug or it just does not work.
Thanks for your help.
Graham
It works fine in my localhost, since it needs custom codes, please provide a test site with the same problem, and fill below private detail box with login details and FTP access, also point out where I can edit you PHP codes, I need a live website to test and debug, thanks
Forgot to mention that I do not have direct access to the php file. I use a plugin called code snippets to insert code.
Thanks for the details, I can login your website, here are what I found
1) Add the PHP codes as I mentioned above here:
hidden link
There isn't any "server 500 error" as you mentioned above
2) Switch to a Subscriber user, Test it in the page you mentioned above:
hidden link
see screenshot: buttons.JPG
Please check this line of the PHP codes:
// setup allowed user's role here
$roles = array('administrator', 'editor');
Here you can setup user roles who can use the Toolset buttons or not.