# How to restrict vendor to post in their categories of services

**URL:** <https://community.hivepress.io/t/how-to-restrict-vendor-to-post-in-their-categories-of-services/17004>\
**Category:** HivePress\
**Tags:** code\
**Created:** [November 4, 2025, 4:12pm UTC](https://community.hivepress.io/t/how-to-restrict-vendor-to-post-in-their-categories-of-services/17004 "2025-11-04T16:12:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jab97139](https://community.hivepress.io/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jab97139](https://community.hivepress.io/u/jab97139)\
**Post date:** [November 4, 2025, 4:12pm UTC](https://community.hivepress.io/t/how-to-restrict-vendor-to-post-in-their-categories-of-services/17004/1 "2025-11-04T16:12:11Z")

</div>

Hello everyone,  
I have a question regarding HivePress and TaskHive. I’ve created categories for my freelancers (vendors) and separate categories for services (listing categories).  
How can I make sure that a freelancer can only post listings in the category they belong to?

For example, there are three categories for both freelancers and services (IT, Digital Marketing, Creativity). I want freelancers in the IT category to be able to offer services **only** in IT, and never in Digital Marketing or Creativity.

thanks for your help

---

<div class="post-metadata">

**Author:** ![ChrisB](https://community.hivepress.io/user_avatar/community.hivepress.io/chrisb/32/14185_2.png) [@ChrisB](https://community.hivepress.io/u/ChrisB)\
**Post date:** [November 4, 2025, 4:16pm UTC](https://community.hivepress.io/t/how-to-restrict-vendor-to-post-in-their-categories-of-services/17004/2 "2025-11-04T16:16:19Z")

</div>

Hi @jab97139,

You can achieve this by using a custom code snippet that restricts the available listing categories based on the vendor (freelancer) category. Here’s a solution provided by the HivePress dev, Ihor, in another topic:

Add the following code snippet to your child theme’s functions.php file or use a plugin like Code Snippets:

```auto
add_filter(
	'hivepress/v1/models/listing',
	function( $model ) {
		if ( hivepress()->helper->is_rest() ) {
			return $model;
		}
		$vendor = \HivePress\Models\Vendor::query()->filter(
			[
				'status__in' => ['auto-draft', 'draft', 'publish'],
				'user' => get_current_user_id(),
			]
		)->get_first();
		if ( ! $vendor ) {
			return $model;
		}
		// Replace the numbers below with your actual vendor and listing category IDs
		if ( array_intersect( (array) $vendor->get_categories__id(), [1] ) ) { // IT
			$model['fields']['categories']['option_args']['include'] = [4]; // IT services
		} elseif ( array_intersect( (array) $vendor->get_categories__id(), [2] ) ) { // Digital Marketing
			$model['fields']['categories']['option_args']['include'] = [5]; // Digital Marketing services
		} elseif ( array_intersect( (array) $vendor->get_categories__id(), [3] ) ) { // Creativity
			$model['fields']['categories']['option_args']['include'] = [6]; // Creativity services
		}
		return $model;
	},
	1000
);

```

How to use:

- Replace 1, 2, 3 with your actual vendor category IDs (IT, Digital Marketing, Creativity).
- Replace 4, 5, 6 with your actual listing category IDs for services.

This will ensure that when a freelancer tries to add a listing, they will only see the service category that matches their own vendor category.

I hope this helps!

Cheers,  
Chris ✌

---

<div class="post-metadata">

**Author:** ![jab97139](https://community.hivepress.io/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jab97139](https://community.hivepress.io/u/jab97139)\
**Post date:** [November 4, 2025, 4:19pm UTC](https://community.hivepress.io/t/how-to-restrict-vendor-to-post-in-their-categories-of-services/17004/3 "2025-11-04T16:19:33Z")

</div>

Hi Chris,  
Thanks

In which database table can I find the différents IDs, please?  
ID for vendors categories  
ID for listing categories

---

<div class="post-metadata">

**Author:** ![ChrisB](https://community.hivepress.io/user_avatar/community.hivepress.io/chrisb/32/14185_2.png) [@ChrisB](https://community.hivepress.io/u/ChrisB)\
**Post date:** [November 4, 2025, 5:41pm UTC](https://community.hivepress.io/t/how-to-restrict-vendor-to-post-in-their-categories-of-services/17004/4 "2025-11-04T17:41:29Z")

</div>

Hi @jab97139,

In WordPress Dashboard, navigate to the edit screen of the vendor/listing category you want to identify, then look at the number portion that’s displayed in the URL. That’s the ID you’re looking for!

I hope this helps!

Cheers,  
Chris ✌

---

<div class="post-metadata">

**Author:** ![jab97139](https://community.hivepress.io/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jab97139](https://community.hivepress.io/u/jab97139)\
**Post date:** [November 4, 2025, 6:24pm UTC](https://community.hivepress.io/t/how-to-restrict-vendor-to-post-in-their-categories-of-services/17004/5 "2025-11-04T18:24:14Z")

</div>

Thanks.

---

<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:** [December 4, 2025, 6:24pm UTC](https://community.hivepress.io/t/how-to-restrict-vendor-to-post-in-their-categories-of-services/17004/6 "2025-12-04T18:24:18Z")

</div>

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