# Mark Duration the predefined "Duration" field non mandatory

**URL:** <https://community.hivepress.io/t/mark-duration-the-predefined-duration-field-non-mandatory/1503>\
**Category:** Bookings\
**Tags:** bookings\
**Created:** [August 26, 2022, 1:01pm UTC](https://community.hivepress.io/t/mark-duration-the-predefined-duration-field-non-mandatory/1503 "2022-08-26T13:01:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tillos](https://community.hivepress.io/letter_avatar_proxy/v4/letter/t/8797f3/32.png) [@Tillos](https://community.hivepress.io/u/Tillos)\
**Post date:** [August 26, 2022, 1:01pm UTC](https://community.hivepress.io/t/mark-duration-the-predefined-duration-field-non-mandatory/1503/1 "2022-08-26T13:01:19Z")

</div>

Hi.  
We have hidden the field “Duration” by a Snippet. This fields is predefined: Listings, Attributes. See attachment. We somehow marked this field as mandatory and then it was hidden.  
Question now: how can I make it non mandatory as the User still is asked to fill it although its not visible anymore.

 ![image](https://community.hivepress.io/uploads/default/original/2X/d/d4f2d5bdae6cece7b010d5c2fe5dd0c849c91d79.png)

---

<div class="post-metadata">

**Author:** ![yevhen](https://community.hivepress.io/user_avatar/community.hivepress.io/yevhen/32/23_2.png) [@yevhen](https://community.hivepress.io/u/yevhen)\
**Post date:** [August 27, 2022, 10:49am UTC](https://community.hivepress.io/t/mark-duration-the-predefined-duration-field-non-mandatory/1503/2 "2022-08-27T10:49:01Z")

</div>

It seems like the **Booking Slot Interval** field which is required for generating time slots for listings

As a possible solution, please try this PHP snippet which sets 10 minutes by default as the booking slot duration when a new listing adding

```auto
add_action(
	'hivepress/v1/models/listing/create', 
	function($listing_id, $listing) {
		error_log('t');
		if(hivepress()->get_version( 'bookings' ) && hivepress()->booking->is_time_enabled($listing)){
			update_post_meta($listing_id, 'hp_booking_slot_duration', 10);
			error_log('te');
		}
	},
	1000,
	2
);

add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes ) {
		if ( isset($attributes['booking_slot_duration']) ) {
			$attributes['booking_slot_duration']['editable'] = false;
		}

		return $attributes;
	},
	1000
);

```

---

<div class="post-metadata">

**Author:** ![system](https://community.hivepress.io/user_avatar/community.hivepress.io/system/32/13990_2.png) [@system](https://community.hivepress.io/u/system)\
**Post date:** [September 26, 2022, 10:49am UTC](https://community.hivepress.io/t/mark-duration-the-predefined-duration-field-non-mandatory/1503/3 "2022-09-26T10:49:29Z")

</div>

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