Does WordPress Allow Blank/Empty Comment Submissions In WordPress?

I’ve got a great Comment Form and Threaded Comments setup by using the native WordPress functions: comment_form and wp_list_comments.

However, I’m trying to also create a custom Contest Comment template for certain posts. I call comments_template('/contest-comments.php', true); conditionally based on whether a certain custom field exists or not. It works great.

I’m trying to make it look along the lines of http://2010.sf.wordcamp.org/attendees/

I only want to show the person’s name wrapped in a link and their avatar. Therefore, I want my comment form to only show the Name, Email, and URL fields. The text area should be hidden.

For the Comment Form, I am passing an empty value for the comment_field key in the $args array I’m passing into comment_form.

This makes the comment form look okay, but when someone submits a comment, they get a warning from WordPress saying that their message was blank.

Any solutions on how to solve this? Thanks!

2 Answers
2

Short answer: It doesn’t, but you can get around this:

add_filter('comment_form_field_comment', 'my_comment_form_field_comment');
function my_comment_form_field_comment($default){
  return false;
}

add_action('pre_comment_on_post', 'my_pre_comment_on_post');
function my_pre_comment_on_post($post_id){
  $some_random_value = rand(0, 384534);
  $_POST['comment'] = "Default comment. Some random value to avoid duplicate comment warning: {$some_random_value}";
}

If you want this only for certain pages, then you should create a custom page template, for eg “boo.php”, and in the code I posted above, only add these filters if the current page template is boo (use $post->page_template to get the current page template when doing the check).

Related questions:

  • Removing the “Website” Field from Comments and Replies?
  • Comment form validation

Leave a Comment