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 have a plugin that does validation on user submitted comments. When validation fails, I want to redirect them back to the comment form, and have their comment still appear in the comment box, so they don't have to type it again.

How can I add custom content to the comment form #content textarea?

share|improve this question
up vote 1 down vote accepted

You can filter 'comment_form_defaults' to change the textarea. You get an array with the default fields as argument:

add_filter( 'comment_form_defaults', 'wpse_67503_textarea_insert' );

function wpse_67503_textarea_insert( $fields )
    if ( /* your condition */ )
        $fields['comment_field'] = str_replace(
            'EXTRA CONTENT</textarea>',

    return $fields;
share|improve this answer
Yes it works, thanks! – gregn3 Oct 8 '12 at 16:27

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.