Hi!
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?
add_filter(
'hivepress/v1/forms/listing_submit',
function( $form ) {
$selected = $_POST['categories'];
foreach ($form['fields']['categories']['options'] as $dpdOpt) {
(if ($dpdOpt['value'] != $selected )) {
$dpdOpt.remove();
}
}
return $form;
},
1000
);