Universal Exceptions

Except dates across all Date fields on all forms.

Code

Filename: gpld-universal-exceptions.php

<?php
/**
 * Gravity Perks // Limit Dates // Universal Exceptions
 * https://gravitywiz.com/documentation/gravity-forms-limit-dates/
 *
 * Except dates across all Date fields on all forms.
 */
add_filter( 'gpld_limit_dates_options', function( $field_options, $form, $field ) {

	foreach ( $field_options as &$_field_options ) {
		if ( ! isset( $_field_options['exceptions'] ) || ! is_array( $_field_options['exceptions'] ) ) {
			$_field_options['exceptions'] = array();
		}
		// Add as many exceptions as you need here.
		$_field_options['exceptions'][] = '04/01/2023';
		$_field_options['exceptions'][] = '07/04/2023';
		$_field_options['exceptions'][] = '12/25/2023';
	}

	return $field_options;
}, 10, 3 );

Leave a Reply

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

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.