Removing all options but selected category

I need to restrict some users from some categories and I therefore want to remove some categories from the category dropdown on the submit listing page. I have previously had this restriction on the deprecated select category page which I have enabled again after using the php snippet found here: Enable the Select Category page (deprecated) in the Add Listing process #hivepress #listings · GitHub

But now I would like to be able to remove categories from the dropdown on the submit new listing page.

I have tried something like this that doesn’t work, but it at least explains what I want to do. Is this the way to go? Or what am I missing?

	function( $form ) {
		 $selected = $_POST['categories'];
		foreach ($form['fields']['categories']['options'] as $dpdOpt) {
			(if ($dpdOpt['value'] != $selected )) {
		return $form;

Please clarify how it should work. Should all listing categories except the selected category be removed after the vendor has selected a category? Or does it work in another way?

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