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 want to set also text comment as required... but in the backend only email and author are possible. Without using a javascript validation, how it is possible? Thank you

share|improve this question
i did not understand a bit! can you please explain a bit more about what is the problem, what you've tried etc.? – HungryCoder Jun 18 '12 at 20:30
I have inserted a comment_form() tag into my template page; in the admin i have set as required the user name and email; but how set as required also the text comment? (without javascript) Thank you – user14550 Jun 20 '12 at 19:36
the comment field may not have * mark but it is essential field. without filling the field, you can not submit the comment. so it is already required field. – HungryCoder Jun 21 '12 at 6:36

You can hook into 'pre_comment_on_post' and inspect $_POST['comment']:

<?php # -*- coding: utf-8 -*-
 * Plugin Name: T5 Require comment text
 * Description: Dies if there is no comment text.
 * Plugin URI:  http://wordpress.stackexchange.com/q/55679/73
 * Version:     2012.07
 * Author:      Thomas Scholz
 * Author URI:  http://toscho.de
 * License:     MIT
 * License URI: http://www.opensource.org/licenses/mit-license.php

if ( ! function_exists( 't5_require_comment_text' ) )
    add_action( 'pre_comment_on_post', 't5_require_comment_text' );

    function t5_require_comment_text()
        if ( ! isset ( $_POST['comment'] ) or '' === trim( $_POST['comment'] ) )
            print 'Please hit your back button and write something useful.';

See wp-comments-post.php for more actions and a way to create a useful back link. I didn’t include one because some browsers restore all filled form fields when the user clicks the back button. A link would prevent this rather useful behavior.

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.