# Prevent vendors from making bookings

**URL:** <https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090>\
**Category:** Bookings\
**Tags:** bookings\
**Created:** [June 2, 2023, 9:55pm UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090 "2023-06-02T21:55:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Munchies4U](https://community.hivepress.io/user_avatar/community.hivepress.io/munchies4u/32/5975_2.png) [@Munchies4U](https://community.hivepress.io/u/Munchies4U)\
**Post date:** [June 2, 2023, 9:55pm UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/1 "2023-06-02T21:55:31Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ihor](https://community.hivepress.io/user_avatar/community.hivepress.io/ihor/32/5_2.png) [@ihor](https://community.hivepress.io/u/ihor)\
**Post date:** [June 3, 2023, 9:51am UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/2 "2023-06-03T09:51:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Munchies4U](https://community.hivepress.io/user_avatar/community.hivepress.io/munchies4u/32/5975_2.png) [@Munchies4U](https://community.hivepress.io/u/Munchies4U)\
**Post date:** [June 3, 2023, 11:51am UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/3 "2023-06-03T11:51:00Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![ihor](https://community.hivepress.io/user_avatar/community.hivepress.io/ihor/32/5_2.png) [@ihor](https://community.hivepress.io/u/ihor)\
**Post date:** [June 4, 2023, 1:43pm UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/4 "2023-06-04T13:43:10Z")

</div>

Please try this code snippet instead:

```auto
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
);

```

---

<div class="post-metadata">

**Author:** ![Munchies4U](https://community.hivepress.io/user_avatar/community.hivepress.io/munchies4u/32/5975_2.png) [@Munchies4U](https://community.hivepress.io/u/Munchies4U)\
**Post date:** [June 5, 2023, 9:23pm UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/5 "2023-06-05T21:23:33Z")

</div>

Working, THANKS Ihor!

---

<div class="post-metadata">

**Author:** ![system](https://community.hivepress.io/user_avatar/community.hivepress.io/system/32/13990_2.png) [@system](https://community.hivepress.io/u/system)\
**Post date:** [July 5, 2023, 9:24pm UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/6 "2023-07-05T21:24:01Z")

</div>

Closed on July 5, 2023, 9:24pm UTC

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

---

<div class="post-metadata">

**Author:** ![Oak](https://community.hivepress.io/letter_avatar_proxy/v4/letter/o/bc79bd/32.png) [@Oak](https://community.hivepress.io/u/Oak)\
**Post date:** [March 10, 2025, 3:38pm UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/7 "2025-03-10T15:38:19Z")

</div>

How can ensure that users who own listings cannot book their own listings? The goal is to prevent them from selecting a date & time in their listing page. Maybe making the button unclickable for them? Is there a solution?

---

<div class="post-metadata">

**Author:** ![andrii](https://community.hivepress.io/user_avatar/community.hivepress.io/andrii/32/2951_2.png) [@andrii](https://community.hivepress.io/u/andrii)\
**Post date:** [March 12, 2025, 10:19am UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/9 "2025-03-12T10:19:09Z")

</div>

Hi,

Please check the solution in this topic.

---

<div class="post-metadata">

**Author:** ![andrii](https://community.hivepress.io/user_avatar/community.hivepress.io/andrii/32/2951_2.png) [@andrii](https://community.hivepress.io/u/andrii)\
**Post date:** [March 12, 2025, 10:19am UTC](https://community.hivepress.io/t/prevent-vendors-from-making-bookings/6090/10 "2025-03-12T10:19:20Z")

</div>

Opened on March 12, 2025, 10:19am UTC


