Skip Navigation

[Resolved] Hide WYSIWYG control in backend custom post

This support ticket is created 2 years, 5 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
- 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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 2 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#2218323
Toolset Screenshot remove:hide this element.png

HI Toolset Support,

I would like to prevent my editor the ability to select heading styles - red circle element in screenshot should be hidden or locked.

Is this possible? If so please provide a solution or code snippet.

Thank you in advance.

#2218529

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

To hide the font selection dropdown from the WYSIWYG type custom fields, for the users with the "editor" role, you can use the following custom code snippet:


add_action('admin_head', 'custom_styles_hide_editor_font');

function custom_styles_hide_editor_font() {
	// get current user
	$current_user = wp_get_current_user();
	// get current user's roles
	$current_user_roles = ( array ) $current_user->roles;
	// target roles to apply the style for
	$target_roles = array('editor');
	// if current user's role is included in the target roles, add the custom style
	if (count(array_intersect($current_user_roles, $target_roles)) > 0) {
		echo '<style>.js-wpt-field.js-wpt-wysiwyg .js-wpt-field-items .mce-widget.mce-btn.mce-listbox.mce-first.mce-btn-has-text {display:none;}</style>';
	}
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

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