Allow reviews with no comment

The below code snippet will allow users to add reviews without entering a comment.

function gd_snippet_allow_empty_comment( $allow, $commentdata = array() ) {
	if ( empty( $commentdata['comment_parent'] ) && ! empty( $commentdata['comment_post_ID'] ) && function_exists( 'geodir_is_gd_post_type' ) && geodir_is_gd_post_type( get_post_type( (int) $commentdata['comment_post_ID'] ) ) ) {
		$allow = true;
	}

	return $allow;
}
add_filter( 'allow_empty_comment', 'gd_snippet_allow_empty_comment', 11, 2 );

function gd_snippet_allow_empty_review( $allow ) {
	$allow = true;

	return $allow;
}
add_filter( 'geodir_allow_empty_review', 'gd_snippet_allow_empty_review', 11, 1 );

function gd_snippet_duplicate_comment_id( $dupe_id, $commentdata ) {
	if ( empty( $commentdata['comment_parent'] ) && ! empty( $commentdata['comment_post_ID'] ) && function_exists( 'geodir_is_gd_post_type' ) && geodir_is_gd_post_type( get_post_type( (int) $commentdata['comment_post_ID'] ) ) ) {
		$dupe_id = 0;
	}

	return $dupe_id;
}
add_filter( 'duplicate_comment_id', 'gd_snippet_duplicate_comment_id', 11, 2 );

function gd_snippet_comment_form_defaults( $defaults ) {
	if ( function_exists( 'geodir_is_page' ) && geodir_is_page( 'single' ) && ! empty( $defaults['comment_field'] ) ) {
		$defaults['comment_field'] = str_replace( esc_html__( 'Enter your review comments here (required)...', 'geodirectory' ), esc_html__( 'Enter your comment here...', 'geodirectory' ), $defaults['comment_field'] );
	}

	return $defaults;
}
add_filter( 'comment_form_defaults', 'gd_snippet_comment_form_defaults', 12, 1 );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us