Snippet to Require different attributes

  1. How do I make the ‘minimum guests per booking’ and ‘maximum guests per booking’ from optional to required in the Rental Hive theme?
  2. How do I enable the lister to select multiple categories when creating a listing? I am able to go in on the WP dashboard on the back end and add more categories, but I would like the lister to be able to select multiple while creating a listing.
1 Like
  1. Please try this PHP snippet
add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes ) {
		if ( isset( $attributes['booking_min_quantity'] ) ) {
			$attributes['booking_min_quantity']['edit_field']['required'] = true;
		}
		
		if ( isset( $attributes['booking_max_quantity'] ) ) {
			$attributes['booking_max_quantity']['edit_field']['required'] = true;
		}

		return $attributes;
	},
	1000
);
  1. Please try this PHP snippet
add_filter(
	'hivepress/v1/forms/listing_submit',
	function( $form ) {
		
		if(isset($form['fields']['categories'])){
			$form['fields']['categories']['multiple'] = true;
		}
		
		return $form;
	},
	1000
);
1 Like

That worked! Thank you!

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