If you use wp-comments-post.php
it would be better to customize comment_form by hook comment_form_default_fields
, I don’t know why you create the new one. But as per of your functions you can handle it like this
add_filter( 'preprocess_comment', 'verify_comment_meta_data', 1, 1 );
function verify_comment_meta_data( $commentdata )
{
$commentdata['review_title'] = ( ! empty ( $_POST['review_title'] ) ) ? sanitize_text_field( $_POST['review_title'] ) : false;
if ( ! $commentdata['review_title'] )
wp_die( __( '<strong>ERROR</strong>: please fill the required fields ( city ).', 'textdomain' ) );
return $commentdata;
}
Actuallly as WordPress comments workflow, the error messages could be handled by fire pre_comment_on_post
, check_comment_flood
, or pre_comment_approved
.