WooCommerce: Enable Product Reviews for Logged Out Verified Customers

In WooCommerce, product reviews are a powerful way to build trust and encourage future purchases.

If you want to avoid spam, you’d usually select the “Reviews can only be left by verified owners” option, so that only logged in customers can leave reviews.

This can be limiting, especially if you want to allow verified buyers who are not logged in to share their feedback, without forcing them to log in first.

In this tutorial, I’ll show you how to customize WooCommerce to allow logged-out verified customers to leave product reviews.

With a simple PHP snippet, we’ll adjust WooCommerce review settings to accept reviews from users who have purchased a product, regardless of their login status. This way, you can enhance the customer experience while maintaining authenticity and security for product feedback.

Let’s dive into the code and get started!

Step 1: Disable “Reviews can only be left by verified owners”

By disabling this setting, we are allowing users to submit product reviews even if they are logged out (so, anyone can post them, including spam bots):

This is only the first step, because now we need some custom code to make sure we “validate” each product review, by double checking if the posted email address is the one of a verified customer.

Step 2: PHP Snippet to Block Product Reviews from Non-WooCommerce Customers

/**
 * @snippet       Reject Review If Email Address Is Not a Woo Customer
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 9
 * @community     https://businessbloomer.com/club/
 */

add_filter( 'preprocess_comment', 'bbloomer_product_review_logged_out_only_verified' );

function bbloomer_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( 'This email address does not appear to be associated with a customer who has purchased this product. Only verified customers can leave a review.' ); 
		}
	}
	return $comment;
}

Result: Review Form For Logged Out Users + Error Message

Once step 1 and step 2 are done, this is the form you see inside the “Reviews” tab on the WooCommerce Single Product Page:

The only difference is that if you use an email address that does not belong to a WooCommerce customer, you will now get a full-page error message:

And this is it… now “verified customers” don’t need to be logged in if they wish to leave a product review, hence your “product review submit” conversion rate may go up!

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *