Restrict listing categories based on vendor (company) categories

Hi all. We are developing a little bit the Jobhive. We are now in blocking point, because we would like to dividing users on two groups: private_users and company_users.

In backend in Company I made two categories (profiles):
1.private 2.company

In Jobs I made three categories:
1.job 2.lookingfor 3.practise

When I choose #1-private (when I filling the account) I want to see (when I add listings) only #2-lookingfor
When I choose #2-company I want to see #1-job & #3-practise.

It means, my client is choosing 1 of 2 profiles - priv or comp in first step and he declare which user he will be.
Than he can add only:
A. looking_for_the_job
OR
B. add_job_offer or add_practise_offer (because company doesn’t want to looking for the Jobs)

Now is:
When I choose #1 in comp. I see in JOBS all three categories.
When I choose #2 in comp. I see in JOBS all three as well.

Can we disapear fe. hmmm… it is little bit funny :wink: but shows you my pov:

If
PRIVATE
Than show
Category looking_for
Else if
Category add_job and add_practise
Done.

:wink::fire:

Hi,

Your request is related to a premium product. Please add the license key to the account settings to access forums for your purchased products and get the Premium Support badge on your profile. If the support for your purchase has expired, please consider renewing it for assistance: Renew Support | HivePress

The licence key, you asked me, is added.

Any ideas, any support, any answer?

Sorry for the delay.

You can use this code snippet to restrict listing categories depending on the vendor (company) category:

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;
		}

		if ( array_intersect( (array) $vendor->get_categories__id(), [ 1, 2, 3 ] ) ) {
			$model['fields']['categories']['option_args']['include'] = [ 4, 5, 6 ];
		} else {
			$model['fields']['categories']['option_args']['include'] = [ 7, 8, 9 ];
		}

		return $model;
	},
	1000
);

Please replace 1,2,3 with the private category ID(s), 4,5,6 with category IDs you want to allow for private persons and 7,8,9 with category IDs allowed for companies.

Hope this helps