wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Disable Tinymce HTML editor for everyone but admin

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will disable the Tinymce HTML editor for everyone but the admin.

snippet :  PHPcopy
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
add_action( 'admin_head', 'disable_html_editor_wps' );
function disable_html_editor_wps() {
	global $current_user;
	if ($current_user->user_level != 10) {
		echo '<style type="text/css">#editor-toolbar #edButtonHTML, #quicktags {display: none;}</style>';

Did you like this post? If so please share it with your friends. Thanks!

  • Anonymous

    Any way to make this user specific?

    • http://wpsnipp.com Kevin Chard

       Yep you could do something like this, should work. Using a list of people within an array and check against the current user. If the users not in the $users array you remove HTML editor.

      add_filter( ‘wp_default_editor’, create_function(”, ‘return “tinymce”;’) );
      add_action( ‘admin_head’, ‘disable_html_editor_wps’ );
      function disable_html_editor_wps() {

          global $current_user;

          $users = array(“dave”, “larry”, “steve”, “ryan”);

          if (!in_array($current_user->user_login, $users)) {
              echo ‘#editor-toolbar #edButtonHTML, #quicktags {display: none;}';

  • Nick

    Thanks, helpful!

    • http://wpsnipp.com Kevin Chard

      Glad to help nick,

  • Braamsviper

    Thanks, just what i needed.

    • http://wpsnipp.com Kevin Chard

      Cool glad I could be of help.

  • Mike

    Hey Kevin — great snippet and learned from it as I do from most of your code. Bizarre follow up, how can we disable the text area altogether? WHAT!!!! LOL
    Ok, I have a custom post type with nothing but custom fields for entry (using the custom fields template plugin) and all the cod is in the custom post php template. I know it has something to do with ‘display: none’  but don’t know what the “display” code is. I think I can put it in a separate style sheet with add_editor_style and use an if (is_singular) condition to show only on the custom post.


    • http://wpsnipp.com Kevin Chard

      Hi Mike, you can remove the Editor from the custom post type by removing that options from the supports array within your custom post type code.

      ‘supports’ => array( ‘title’, ‘editor’, ‘excerpt’, ‘custom-fields’, ‘thumbnail’ ),

  • http://www.avinashdsouza.me Avinash D’Souza

    Hey Kevin,

    I’d really love to see this code still being active…any chance of an update for WP 3.5?

    As of now, I don’t see this working…

    • mano

      Avinash D’Souza:
      this works for me! – replace the style part for this:

      body.wp-admin div#wpwrap div#wpcontent div#wpbody div#wpbody-content
      div.wrap form#post div#poststuff div#post-body.metabox-holder
      div#post-body-content div#postdivrich.postarea

  • steve

    Nice snippet. I had to use the following CSS to make this work: a#content-html {display: none !important;}

  • Fredrik Persson

    It seems that you can use firedebug and enable it again and use it and still write javascript.
    Not safe.

  • Ben

    Disable and display:none; aren’t really the same thing…

  • Pingback: WordPress Conditional Tags (And Snippets) for Beginners()