Hide specific categories on Add Listing

Hi, I would like my users to be able, when submitting a listing, to choose just some specific categories and not any of them. I don’t want to manually delete the categories I am not using cause I could use them in the future so I just want my users to be able to choose between some categories and hide the others from the Category selection dropdown in the Add listing form.

Ty!!

Found the solution:

add_filter(
	'hivepress/v1/models/listing/fields',
	function($fields, $model){
		$disabled_categories_ids = [1,2,3];
		
		if(isset($fields['categories']['options'])){
			foreach($disabled_categories_ids as $category_id){
				unset($fields['categories']['options'][$category_id]);
			}	
		}
		
		return $fields;
	},
	10000,
	2
);
2 Likes

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