Restrict certain categories to verified vendors

Hello. Is there any way to restrict certain categories to verified vendors?

Hi,

Unfortunately, there’s no such feature, it would require a custom implementation. If you are familiar with coding or have a developer, we can provide general guidance.

Thanks for your response. I do have a developer and would appreciate whatever guidance you have to share.

Please provide more details about the required functionality, do you mean allowing only verified vendors to add listings to specific listing categories? Or this is related to vendor categories (selected in the profile form during the registration).

Thanks

Yes. I mean allowing only verified vendors to add listings to specific listing categories.

Please try this code snippet, replace 1,2,3 with IDs of categories allowed for non-verified vendors:

add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $args, $form ) {
		$listing = $form->get_model();

		if ( ! $listing ) {
			return $args;
		}

		$vendor = $listing->get_vendor();

		if ( ! $vendor ) {
			return $args;
		}

		if ( ! $vendor->is_verified() ) {
			$args['fields']['categories'] = array_merge(
				$args['fields']['categories'],
				[
					'options'     => 'terms',
					'option_args' => [
						'taxonomy' => 'hp_listing_category',
						'include'  => [ 1, 2, 3 ],
					],
				]
			);
		}

		return $args;
	},
	1000,
	2
);

Hope this helps

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