Prevent vendors from making bookings

Hi there team HP

I have previously come across a spinet that prevents vendors accounts making any bookings. I know there is a snippet that prevents vendors from booking their own listings to prevent card frauds, but I need the one that prevents vendors accounts from making any bookings. Please can you supply me the link to the snippet as I can’t seem to find it now.

THANKS!

Please post a snippet that you’re currently using or send a link to the topic with the snippet, we’ll check if it’s easy to adjust it to prevent all the bookings for vendors.

Hi there Ihor
Its a snippet that I got here on the community, can’t remember the topic name now, so here is the snippet’s code so Vendors can’t book their own listings to prevent possible fraudulent behavior with stolen bank cards.

add_filter(
	'hivepress/v1/templates/listing_view_page/blocks',
	function($blocks, $template){
		$listing = $template->get_context('listing');
		
		if(!$listing){
			return $blocks;
		}
		
		$vendor = $listing->get_vendor();
		
		if(!$vendor){
			return $blocks;
		}
		
		$user = $vendor->get_user();
		
		if(!$user || get_current_user_id() !== $user->get_id()){
			return $blocks;
		}
		
		hivepress()->template->fetch_block($blocks, 'booking_make_form');
		
		return $blocks;
	},
	1000,
	2
);

So we would like to prevent Vendors from being able to make any bookings, their own listings or other vendor’s listings from their Vendor/Contributor type accounts. I’m sure I came across a snippet here on the community somewhere, but I can’t seem to find it again.

Please try this code snippet instead:

add_filter(
	'hivepress/v1/templates/listing_view_page/blocks',
	function($blocks, $template){
		if(!is_user_logged_in() || !current_user_can('edit_posts')){
			return $blocks;
		}
		
		hivepress()->template->fetch_block($blocks, 'booking_make_form');
		
		return $blocks;
	},
	1000,
	2
);

Working, THANKS Ihor!

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