Change WordPress user roles and capabilities › Forums › How to or FAQ › How to disable the Text Editor? – just Visuell Editor should be displayed
- This topic has 6 replies, 2 voices, and was last updated 8 years, 2 months ago by kstockl.
-
AuthorPosts
-
03/09/2016 at 20:06 #2704kstocklParticipant
I´m on the way to building a News Website where Authors are able to write their own Posts/Articles.
I want to disable the Text Editor (HTML Editor Button/Tab) for this Authors. They should just be able to see the Visuell Editor when the writing a new Post/Article.a) Can this be done by settings inside the User Role Editor Pro?
b1) If not – how I am able to disable the Text Editor for Users per Role? And is planned to integrate a function where this is possible in the future?
b2) Are there any Plugins which are able to diable this function or how can this be realized?
Thanks for your answer
Wit best Regards, Karl Stöckl05/09/2016 at 05:00 #2708VladimirKeymasterHi Karl,
Add this code to your active theme functions.php file or setup it as must use plugin:
function my_editor_settings($settings) { if (!current_user_can('administrator')) { $settings['quicktags'] = false; } return $settings; } add_filter('wp_editor_settings', 'my_editor_settings'); add_filter('wp_default_editor', create_function('', 'return "tinymce";'));
05/09/2016 at 06:13 #2709kstocklParticipantGood Morning Vladimir,
thank´s a lot of this advice 🙂
So just a question – if I include this code snippet into my Theme functions.php it works perfect. But can you advice me how to integrate it as a Must USE plugin? I tried to do this but it does not work. What did I do?
1. I created a folder in /wp-content with this structure /wp-content/mu-plugins
2. I pasted your code-snippet into my Text Editor and saved this file with name: editor.php
3. Uploaded this file into the new created directory: /wp-content/mu-pluginsBut when I tried this it wasn´t working. The snippet was printed as text line to the head of my Website. It seems that I just made something wrong.
By the way I didn´t know about the must use Plugin till now. So ecery day I learn new secrets 😀
Thank´s for your reply,
With best Regard, Karl
05/09/2016 at 06:19 #2710VladimirKeymasterYou made all correctly except one thing: add as a 1st separate line to the file editor.php the tag
<?php
It will show to PHP interpretator where a PHP code starts.
05/09/2016 at 06:35 #2711VladimirKeymasterIf you wish to have more control it’s possible to integrate this code snippet with User Role Editor as the additional options for role:
add_filter('ure_role_additional_options', 'add_visual_editor_only_option', 10, 1); function add_visual_editor_only_option() { $item = URE_Role_Additional_Options::create_item('visual_editor_only', esc_html__('Visual Editor Only', 'user-role-editor'), 'admin_init', 'ure_remove_text_editor'); $items[$item->id] = $item; return $items; } function ure_remove_text_editor() { add_filter('wp_editor_settings', 'ure_editor_settings'); add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') ); } function ure_editor_settings($settings) { if (!current_user_can('administrator')) { $settings['quicktags'] = false; } return $settings; }
05/09/2016 at 06:47 #2712kstocklParticipantI tried this meanwhile but with one difference:
<?php function my_editor_settings($settings) { if (!current_user_can('administrator')) { $settings['quicktags'] = false; } return $settings; } add_filter('wp_editor_settings', 'my_editor_settings'); add_filter('wp_default_editor', create_function('', 'return "tinymce";')); ?>
Here I got the 500 Error Message
So I thought just to put this code snippet without the
<?php
?>
.My mistake was at the last line. Here I added
?>
Thank you so much for your time and your support. Now with your advice the Editor is doing the job as I want.
With best Regards from Austria,
Karl05/09/2016 at 07:13 #2714kstocklParticipantAh, I see… if I want take control for different Roles I have just to paste the Code in the Theme functions.php. Within this I´m able to to select different User Roles to be able to have the HTML Editor for advanced Article crating while normal Users are only able to use the Visual Editor.
Great Advice 🙂Vladimir, may I suggest to you to maybe include this Feature function in one of your next Plugins Update? So that this special Editor Functions could enabled/disabled by default within User Roles Editor Plugin without the need of edit the Theme Functions.php?
1.) So it would not be effected when Theme updates overwrite the changed settings.
2.) It would be in my opinion a great feature addon too to control which of the Users are able to have full control of the HTML Editor. Some of the Users couldn´t break any Site anymore with wrong HTML Codes.
3.) Admins would have less headache 😉 -
AuthorPosts
- You must be logged in to reply to this topic.