Skip Navigation

[Resolved] Extraneous tabs appearing on front end forms

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 6 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#615800
Screenshot.png

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?

#615878

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

#616393

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

#616594

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

#616598

Forgot to mention that I do not have direct access to the php file. I use a plugin called code snippets to insert code.

#616600
buttons.JPG

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.

The forum ‘Types Community Support’ is closed to new topics and replies.