Can we restrict reviews to users who have actually bought from the vendor?

Hello there,

first and foremost, I’m enjoying the features and the easy of use of taskhive! so great work!

I have a question though, I don’t want general users to add reviews to services or vendors if they didn’t actually buy the service from this vendor.

Can it be done? Any advice?
Thank you

Thanks!

Yes, if you’ve installed Marketplace, please check the “Restrict reviews to buyers” option in HivePress>Settings>Orders section.

Is there an option to do same restriction with bookings plugin instead of marketplace? As we use Booking plugin only, as Marketplace redirects to WooCommerce, and bookings only plugin is better solution for us.

Please try this PHP snippet

add_filter( 
	'hivepress/v1/models/review/errors', 
	function ( $errors, $review ) {
		
		if ( empty( $errors ) && hivepress()->get_version('bookings') ) {

			// Get listing.
			$listing = $review->get_listing();
			
			if ( $listing && hivepress()->booking->is_booking_enabled( $listing ) ) {
				
				// Get booking.
				$booking = HivePress\Models\Booking::query()->filter(['listing' => $listing->get_id(), 'user' => get_current_user_id(), 'status__in' => hivepress()->booking->get_blocked_statuses()])->get_first_id();
				
				if ( !$booking ) {
					$errors[] = 'Only buyers can submit reviews';
				}
			}
		}
		
		return $errors;
	}, 
	1000, 
	2 
);
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.