How to prevent users from posting multiple reviews on a single post

WP Product Review allows users to post as many reviews as they want to, this is the default behavior.

It can be changed by adding the snippet below in your functions.php file.
Adding this prevents users from posting another review on that post, but allows them to post new comments. This only works for logged in users.

function wppr_disable_comments( $disable, $review ) {
	if ( is_singular() && is_user_logged_in() ) {
		$current_user = wp_get_current_user();
		$usercomment = get_comments( array( 'user_id' => $current_user->ID, 'post_id'=>$review->get_ID() ) );
		return ! empty( $usercomment ) ;
	}
}
add_filter( 'wppr_disable_comments', 'wppr_disable_comments', 10, 2 );
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