0

I use a plugin that loads pre-defined HTML for my posts. I don't need the Visual editor, so I've disable it for everybody.

Also, I want TinyMCE not to mess with my code. Nothing, no auto formatting or cleaning up the code. For that I've added some code to my functions.php to guarantee it will work:

/** Disable Visual */
add_filter( 'user_can_richedit' , '__return_false', 50 );


/** Stop TinyMCE auto formating */
remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');
remove_filter('comment_text', 'wpautop');
remove_filter('the_title', 'wpautop');

The problem is, it is working fine for the Admin and the Editor, but not for the other user roles (Contributor and Author). So the editor keeps removing input tags, replacing some HTML to shortcodes and so on.

Why does it happen and how can I disable these editing for everyone?

  • If you want Authors and Contributors to be able to have aribitrary HTML in their posts then you need to give them the unfiltered_html capability. This means that could also post malicious scripts, so be careful who you let become Contributors. But honestly, it sounds like your really stretching what the editor’s supposed to be used for. Sounds like you’d be better off with custom templates with custom fields. – Jacob Peattie Jan 15 at 4:41
  • This makes sense. But how am I going to allow the Authors and Contributors to have my input that has a little javascript on it, and stop from creating shortcodes? – Henrique Barcelos Jan 15 at 4:54
  • I found out I can use these, but can you help me make them as one function? function add_author_full_edit() { $role = get_role( 'author' ); $role->add_cap( 'unfiltered_html' ); } add_action( 'admin_init', 'add_author_full_edit'); function add_colab_full_edit() { $role = get_role( 'author' ); $role->add_cap( 'unfiltered_html' ); } add_action( 'admin_init', 'add_colab_full_edit'); – Henrique Barcelos Jan 15 at 5:11
  • Just use a plugin like User Role Editor. – Jacob Peattie Jan 15 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.