In WooCommerce, product reviews are an effective way to build trust and encourage future purchases. To avoid spam reviews, we usually enable the option “Reviews can only be left by ‘verified owners'”. However, this can bring some restrictions to buyers who need to post reviews—for example, when a user who has already purchased a product is not logged in, they cannot post a product review.
In this tutorial, I will show you how to customize WooCommerce to allow guest buyers to post product reviews while still maintaining verification.
Step 1: Disable the “Reviews can only be left by ‘verified owners'” Option
By disabling this setting, we allow users to submit product reviews even if they are logged out (therefore anyone can post a review, including spam bots):

This is just the first step. Next, we need some custom code to ensure that we “verify” each product review. In the code below, we verify whether the user posting the review is a buyer who has already purchased the product by checking the reviewer’s email address.
Step 2: Use PHP Code to Restrict Reviews to Verified Customers
Add the following code to your theme’s functions.php file or a custom plugin:
add_filter( 'preprocess_comment', 'wprs_product_review_logged_out_only_verified' );
function wprs_product_review_logged_out_only_verified( $comment ) {
if ( 'product' === get_post_type( $comment['comment_post_ID'] ) ) {
if ( $comment['comment_author_email'] && ! $comment['user_id'] && ! wc_customer_bought_product( $comment['comment_author_email'], '', $comment['comment_post_ID'] ) ) {
wp_die( 'Sorry, you have not purchased this product. Only users who have purchased the product can post reviews.' );
}
}
return $comment;
}
Review Form + Error Message for Logged-out Users
After completing Step 1 and Step 2, you will see the following form in the “Reviews” tab on a single WooCommerce product page:

The only difference is that if you use an email address that has not purchased the product to post a review, after submission, you will be redirected to an error message page.

Now “verified customers” can post reviews without needing to log in. As a result, your product review submission conversion rate may increase!
