WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to disable the tinyMCEeditor in wordpress so it is readonly if the post has already been published. I already have the logic for determining if the post is published (by using $post object's post_status variable)but I have not found a solution for setting the readonly parameter in tinyMCE to true.

Cross-Post from StackOverflow

share|improve this question
up vote 4 down vote accepted

You can hook into tiny_mce_before_init to modify the TinyMCE arguments to set the readonly attribute.

For example (using PHP 5.3):

add_filter( 'tiny_mce_before_init', function( $args ) {

    // do you existing check for published here
    if ( 1 == 1 )
         $args['readonly'] = 1;

    return $args;
} );

This will make the TinyMCE readonly, however it won't make the HTML editor readonly (that's not TinyMCE) and it also won't stop people using the Media Upload to insert images. However, that might not be an issue - because I would recommend you implement some server-side checking to prevent edits, as it's always possible for someone to send whatever content they want from the browser by manipulating the DOM etc.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.