Allow Reviews from Verified Buyers Only & Stop Fake Ones in WooCommerce
Have you ever wanted to leave a review on a website but got this message?
“Only logged in customers who have purchased this product may leave a review.”
And wondered how you can create it for your own store?
Before getting there, let’s all agree that customer reviews can be a double-edged sword.
It could benefit you by adding a social proof element to your products, but your competitors could use them in unethical ways to destroy your reputation.
So you need to make sure you don’t fall into the trap of fake negative reviews. Keep reading to learn how to only allow reviews from verified buyers in WooCommerce.
The Simple Way of Allowing Reviews From Verified Buyers
This way is very simple and straightforward, you would just adjust the WooCommerce settings to only allow verified purchases, following these steps:
- WooCommerce → Settings → Products → Reviews can only be left by “verified owners”
Using this simple step the only reviews allowed would be by logged-in users who’ve already bought the product.
The downside of this method though is that it doesn’t account for guest purchases, users who haven’t created an account while buying the product won’t be able to leave a review if you follow this method.
How to Modify the WooCommerce Review System to Recognize Guest Purchases?
Modifying the WooCommerce review system to recognize guest purchases involves custom coding or using plugins that can link reviews to guest orders.
A typical approach might include developing a custom function that checks the order database for a matching email address and product ID when a review is submitted. If a match is found, the review could be marked as “verified.”
Here’s a simplified example of what the code might look like:
function verify_guest_reviewer($comment_author_email) { $args = array( 'post_type' => 'shop_order', 'post_status' => array('wc-completed'), 'numberposts' => -1, 'meta_query' => array( array( 'key' => '_billing_email', 'value' => $comment_author_email, 'compare' => '=', ), ), ); $orders = get_posts($args); if ($orders) { // The guest has completed orders, proceed with verifying the review return true; } else { // No completed orders found for this email, do not verify the review return false; } } // Hook into the review submission process to verify guest reviewers add_filter('pre_comment_on_post', 'verify_guest_reviewer');
This code is a basic illustration and would need to be adapted to specifically check if the guest user has purchased the product being reviewed. It checks for completed orders by the guest’s email address. Remember, implementing this requires careful testing to ensure it doesn’t interfere with the normal operations of your site and respects privacy and security standards.