X

Disable Tinymce HTML editor excluding array of users

Easy Digital Downloads Review - pricing

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 )


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>';
    }
} 

Comments  Leave a Reply

  1. 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

    1. 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’ ),

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!