I think 'pre_comment_on_post'
is a better hook to use, although you’ll have to reproduce some logic from “wp-comments-post.php” to use it, eg:
add_action( 'pre_comment_on_post', function ( $comment_post_ID ) {
$go_back = sprintf( __( '<br><a href="https://wordpress.stackexchange.com/questions/207612/javascript:history.go(-1)">Back to "%s" Article</a>' ), get_the_title( $comment_post_ID ) );
// Part-copied from "wp-comments-post.php", with $go_back tagged onto error strings.
$comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null;
$comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null;
$comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;
$user = wp_get_current_user();
if ( get_option('require_name_email') && !$user->exists() ) {
if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) {
wp_die( __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ) . $go_back, 200 );
} elseif ( ! is_email( $comment_author_email ) ) {
wp_die( __( '<strong>ERROR</strong>: please enter a valid email address.' ) . $go_back, 200 );
}
}
if ( '' == $comment_content ) {
wp_die( __( '<strong>ERROR</strong>: please type a comment.' ) . $go_back, 200 );
}
} );