[ad_1]
This solution demonstrates how to limit the time slots in the Gravity Forms Date Time field add-on to 30-minute intervals with a 15-minute gap after each slot. By dynamically generating the time slots within the specified range, you can create a more user-friendly time selection interface.
add_filter('gf_awp_calendar_allow_time', 'filter_gf_awp_calendar_allow_time', 10, 2);
function filter_gf_awp_calendar_allow_time($allow_time, $form) {
$start_time = strtotime('09:00');
$end_time = strtotime('17:00');
$time_slots = array();
while ($start_time < $end_time) {
$time_slots[] = date('H:i', $start_time);
$start_time += (30 * 60); // Add 30 minutes
$start_time += (15 * 60); // Add 15 minutes gap
}
return $time_slots;
}
This code snippet will generate time slots from 9:00 AM to 5:00 PM with 30-minute intervals and a 15-minute gap after each slot, ensuring a more structured and convenient time selection experience for users.
Add this code in your child theme functions.php
