Quantcast
Channel: Snippets Archives - Gravity Wiz
Viewing all articles
Browse latest Browse all 196

How to Block a Date Range with Gravity Forms Datepicker

$
0
0

This article requires the GP Limit Dates perk. Buy Gravity Perks today to get this perk plus 25 other galatic Gravity Forms plugins!

View this code snippet on GitHub.

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?

  1. Install and activate Gravity Forms, Gravity Perks, and GP Limit Dates.
  2. Copy and paste the snippet into your theme’s functions.php file.
  3. Modify the “Start Date” and “End Date” options at the top of the snippet to meet your needs. Full usage instructions are below.

Usage

Once installed, this snippet is easy to configure.

  1. 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).

    gpld_limit_dates_options_FORMID_FIELDID

  2. Specify Your Date Range

    Find the $start_date and $end_date variables 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.

    View this code snippet on GitHub.
  3. Admire Your Handiwork

gp-limit-dates-block-date-range-datepicker

That’s all folks!

How’d that work for you? Leave us a comment below.


Viewing all articles
Browse latest Browse all 196