I made a few comment meta field and they work well.

Now I need to set comment text as no require.

I found this solution but don't work for me.

add_action( 'pre_comment_on_post', 'allow_empty_comment_text' );

function allow_empty_comment_text( $text = '' )
    if ( ! isset ( $_POST['comment'] ) or '' === trim( $_POST['comment'] ) )
        $img = '/* Process uploaded image here, create an <img> tag. */'    
        $_POST['comment'] = '<img>'; // use a real img tag here

any solution please.


I solve it:

step 1 - insert a random number in text body, because WordPress prevent users that duplicate comments.

step 2- set display:none to textarea of comment field

Finally copy this code in functions.php:

add_filter( 'comment_form_field_comment', 'set_default_comment_text', 10, 1 );

function set_default_comment_text() {

    $post_id = get_the_title();

    global $current_user;


    $comment_rand = rand(10,100000);

    $comment_field = '<textarea style="display:none" id="comment" name="comment" cols="45" rows="8" maxlength="65525" readonly="readonly">'.$comment_rand.'</textarea>';

    return $comment_field;

I think you can use $_POST['comment'] = 'NO_COMMENT' then when display the comment you strip that string by "comment_text" filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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