Disable Toolset GUI Buttons on FrontEnd TinyMCE Instances

Toolset buttons (Fields and Views, Forms, Access) are visible on all TinyMCE Instances, hence as well in FrontEnd Forms using TinyMCE Editor of WordPress (wp_editor), when users with role author+ and when insert media option is enabled in the editor.

You can disable with the following code:

* Remove Toolset buttons on front-end editors
* which appear for role author+ when 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' );