I am trying to hide the Booking Available To and From fields. I was able to accomplish that by using the snippet below. But, when the listing is added, it throws an error “Booking Available To: is required”. So, I added the second snippet to make it optional. I set the priority higher and lower, yet both didn’t work.
If I use both snippets together, the Booking Available To and From always show (not hidden despite the snippet) and they are correctly Optional. If I use just one of either, they work fine. I need to both hide and ensure the Required error does not show.
HIDE:
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
unset( $form['fields']['booking_max_time'] );
unset( $form['fields']['booking_min_time'] );
return $form;
},
1000
);
And Don’t make required:
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
$form['fields']['booking_max_time']['required'] = false;
$form['fields']['booking_min_time']['required'] = false;
return $form;
},
1000
);