Skip Navigation

[Resolved] additional button in latest version of CRED

This thread is resolved. Here is a description of the problem and solution.

Problem:
When you enalbe "Allow Media Upload Button" in a CRED Form, with it also the Toolset, Access and CRED buttons will appear in the TinyMCE instance on the Front End.
How can I remove it, but keep the Media Upload Button?

Solution:
There are a few hooks you can use, in your theme's functions.php:

/**
* 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 );
 
if ( 19 == $postID ) { // edit with your own condition
// 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' );
return $roles;
} );
}
}
add_action( 'init', 'remove_toolset_buttons' );
This support ticket is created 7 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 7 replies, has 2 voices.

Last updated by kelvinL-2 7 years, 1 month ago.

Assisted by: Beda.

Author
Posts
#494138
Screen Shot 2017-02-26 at 10.23.30 PM.png

Dear Sir/Madam,

After upgrade the CRED to 1.8.6, there are two extra ACCESS and VIEWS buttons show in the WYSIWYG custom field, how can I hide them? Actually I don't need them.

Best regards,

Kelvin.

#494310

This should not happen.
In my tests, it only happens if I am logged in as Author or above, and only if I have the "Allow Media Insert button in Post Content Rich Text Editor" active on the respective CRED Form.

Still, in my opinion, those buttons should not be present, as we have no choice to edit the settings for them.

I need to report this.
For now, the chance is to either use a lower level Custom Role, create your Own Custom Role, or disable the "Allow Media Insert button in Post Content Rich Text Editor" in CRED.

#495376

I have to apologise, this is a new feature.
I have missed this, and wrongly stated, or better, confirmed to you it's a BUG.

As from now on those Buttons will be available in the Front End Edit Tools.

Possible ways to remove it are:
- use a different role (see my previous post)
- uncheck the "Allow Media Insert button in Post Content Rich Text Editor"

Please let me know if I can assist you further.

#496426

Dear Beda,

I tried to uncheck the "Allow Media Insert button in Post Content Rich Text Editor" but the default WP Add Media also removed.

If lower the role, it will affect other capability on edit/delete post. I don't think changing the role is the solution to remove the button.

I suggest Toolset to consider separate the Allow Media Insert and its Toolset button Insert setting.

Currently I use css to hide the button from front-end

span.button.js-wpv-fields-and-views-in-toolbar {
  display: none;
}
#497061

I already filed a request to think this through.

I completely agree that for once, Media Upload is completely irrelated to Access and Views Buttons, and as such it needs a separate setting, and for second, that it is a pain to update all users on a existing site.

I cannot change the situation right now, but I'll push for a change here.

Thank you for your voice, it will help to improve the Toolset.

#497467

Dear Beda,

Yes, thanks for your help to report this to the development team. Should I keep this thread to wait for the reply or it can close now?

Best regards,

Kelvin.

#497741

I suggest we close it.
You would then find the change in our Changelog, once it gets (if) implemented.

Meanwhile, there are a few hooks you can use, in your theme's functions.php:

/**
* 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 );

if ( 19 == $postID ) { // edit with your own condition
// 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' );
return $roles;
} );
}
}
add_action( 'init', 'remove_toolset_buttons' );
#497902

Dear Beda,

Noted with thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.