wordpress snippets last updated   : July 14, 2014
we now have 634 snippets

Disable Tinymce HTML editor excluding array of users

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will disable tinyMCE for everyone but the specified list of users. This is an updated version of this snippet ( Disable Tinymce ).

( example screenshot )
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;
    get_currentuserinfo();
    // change users in list
    $users = array(
                              "dave",
                              "larry",
                              "steve",
                              "ryan"
                            );
    if (!in_array($current_user->user_login, $users)) {
        echo '<style type="text/css">#editor-toolbar #edButtonHTML, #quicktags {display: none;}</style>';
    }
}

  • Mike

    Hi Kevin — your snippets are great, but my needs are many LOL. Ok, is there a simple way to either 1) disable the tinymce editor for a specific post type, 2) disable the text entry area altogether for this post type (I’m using only custom field template boxes for entry)? The latter is what I really need. I know there is and have been Googling for hours when I ran across the above snippet.

    Thanks, Mike

    • 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’ ),

jqsnipp.com | we just launched jquery snippets website