Skip Navigation

[Resolved] Is there a way to remove capability to wysiwyg editor in custom posts?

This support ticket is created 2 years, 9 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.

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 2 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#2317833

I would like to limit the post content to text only. (Remove the ability to embed links)

I found this link, but it is 404.
https://toolset.com/forums/topic/removing-buttons-for-certain-user-roles-for-the-post-editor/

Thanks!

#2318099

Hello,

Are we talking about creating new post in frontend with a Toolset post form or in WordPress dashboard side?

If it is in frontend with a Toolset post form, you can edit your post form, use a generic multiple-lines field to replace the post content field:
https://toolset.com/course-lesson/adding-generic-fields-to-forms/

After user fill and submit the post form, use action hook cred_save_data to trigger a PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
Save the multiple-lines field value into post content:
https://developer.wordpress.org/reference/functions/wp_update_post/

#2319001

We have hundreds of user members with this field in use. How will changing this field effect current user profile posts?

What we really need is a way to remove links and linked text from the text. How does Toolset do it on the support messages? When I post a link to my site it is hidden from public view.

#2319111

In you case, it does not needs custom codes, you just needs to use a generic multiple-lines field to replace the post content field, for example:

[cred_generic_field type='textarea' field='post_content']
{
"required":0,
"default":""
}
[/cred_generic_field]

The ticket you mentioned above was using custom codes to hide editor buttons, and it was outdated, you can try it at your own risk. I copy/paste the solution from that ticket here:

1. Please 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 example, you can replace those with your roles as needed. These are in the if conditional statement.

2. Download & extract this file >> and place this css file in the folder in your site:
wp-content/themes/et/ (inside your theme folder)
CSS file: hidden link

#2319481

Hi will give that a try, but the bigger issue (I just realized) is that users are submitting email addresses and urls in the post content. Like Toolset, we are trying to protect our users from having these items public facing. We have a messaging app for users to contact each other inside the site.

When a Toolset support user submits a url, the url shows as "hidden link". How can we do that with post content?

Thank you!

#2320205

For the new question:

When a Toolset support user submits a url, the url shows as "hidden link". How can we do that with post content?

There isn't such kind of built-in feature within Toolset forms plugin, you might consider custom codes, for example
1) Create a custom shortcode with a PHP function:
https://developer.wordpress.org/reference/functions/add_shortcode/
2) In this PHP function, get the post content:
https://developer.wordpress.org/reference/functions/get_the_content/
Find and replace those URLs with "hidden link"
hidden link
And output the result