How to Block a Date Range with Gravity Forms Datepicker
This article requires the Gravity Forms Limit Dates perk.
Buy Gravity Perks to get this perk plus 47 other premium Gravity Forms plugins!
GP Limit Dates provides an easy-to-use user interface for limiting selectable dates in a Gravity Form Date field. By default, we designed the user interface to give you complete control over the selectable dates.
But what if you wanted to select a large block of dates to disable? For example, the entire summer?
You could certainly go through manually and limit each day of the summer but this would take some time to do and besides, we have a better solution for you!
In this article, we will show you how to block a date range with Gravity Forms Datepicker.
How do I get started?
- Install and activate Gravity Forms, Gravity Perks, and GP Limit Dates.
- Copy and paste the snippet into your theme’s functions.php file.
- Modify the “Start Date” and “End Date” options at the top of the snippet to meet your needs. Full usage instructions are below.
Once installed, this snippet is easy to configure.
Designate Your Date Field
Replace the numeric values in the filter name with your Gravity Forms form ID (FORMID) and the Date field ID (FIELDID).
Specify Your Date Range
$end_datevariables at the top of the code snippet. Replace each with the dates for your desired date range. The dates should be specified in the “YYYY-MM-DD” format.
$start_date = '2016-07-15'; $end_date = '2017-01-01';
Admire Your Handiwork
That’s all folks!
How’d that work for you? Leave us a comment below.