Formidable Calendar Custom Time Slots Per Hour of the Day

Formidable form building is one of the best and most extensive, fully customisable, WordPress plugin out there. You can create all types of forms you can think of. From a simple contact form, to a complex booking form, or even a full-featured user database with lots of filters and search features.

But even if Formidable Pro is this powerful, there are still some things that Formidable Pro cannot do. One is allowing different number of slots per hour of the day. Out of the box, Formidable’s calendar and time field can let you limit the number of slots per day by a few lines of code.

For example, you can add 30 slots per time interval per day by adding this filter and functions to your functions.php file in WordPress:

add_filter(‘frm_allowed_time_count’, ‘allow_30_registrations’, 10, 2 );
function allow_30_registrations( $times_selected, $time_key ) {
if ( $time_key == ‘field_key_here’ ) { // change field_key_here to the key of your time field
$times_selected = 30;
}
return $times_selected;
}

Credits to Steph Wells tip here.

But how about if you want to have different time slots per day? For example you only want 30 slots every Monday, 20 slots every tuesday, 10 slots every Wednesday, and 5 slots for the rest of the days? How can you do it? Currently, it’s not available in the knowledgebase of Formidable Pro, but you can do it by adding these few lines in the function above.

So the result will be:
add_filter(‘frm_allowed_time_count’, ‘allow_30_registrations’, 10, 2 );
function allow_30_registrations( $times_selected, $time_key ) {
if ( $time_key == ‘field_key_here’ ) { // change field_key_here to the key of your time field
$day_of_the_week = date( ‘N’, strtotime( $_POST[‘date’] ) );
if ( $day_of_the_week == 1) {
$times_selected = 10;
}
elseif ( $day_of_the_week == 6) {
$times_selected = 15;
}
return $times_selected;
}

But what if you want to block time slots per specific time of a specific day? For example, Sunday 9:00 AM = 10 slots, Sunday 10:00 AM = 30 slots, Sunday 1:00 PM = 40 slots, Sunday 5:00 PM = 50 slots. How can you do it? By default, you cannot use the frm_allowed_time_count filter, but you can modify the plugin core file to achieve such feature (Hopefully Formidable will include this in their next update).

The core plugin fie that you need to modify is FrmProFieldsController.php and add an additional rule for frm_allowed_time_count filter.

You can also block days of the week, block out specific dates, add date range, set minimum date for the second field date, and do so much more. Check out this knowledgebase article: https://formidablepro.com/knowledgebase/frm_date_field_js/


Comments

2 responses to “Formidable Calendar Custom Time Slots Per Hour of the Day”

  1. Wow this is exactly what I need! Thank you Bryan!

  2. Hi Bryan,
    Thank you – your code snippets are close to what I need to do in Formidable Forms but need a couple of tweaks.
    1. I have a drop-down field where users select an option and then start time and finish time – I’d like to default the time options to 12 hourly so when choosing option1 and 09H00 then the finish time will default to 21H00.
    2. A separate option in another field I want users to be able to choose 2 hourly slots only and have multiple users be able to book these each day.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.