Skip to content

Instantly share code, notes, and snippets.

@spivurno
Last active September 22, 2016 09:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spivurno/22cde09a3eabfc3a76c0b8fa5f6996d4 to your computer and use it in GitHub Desktop.
Save spivurno/22cde09a3eabfc3a76c0b8fa5f6996d4 to your computer and use it in GitHub Desktop.
Gravity Perks // GP Limit Dates // Dynamically Enable Specific Dates
<?php
/**
* Gravity Perks // GP Limit Dates // Dynamically Enable Specific Dates
*/
// replace "123" with your form ID, and "1" with your Date field ID
add_filter( 'gpld_limit_dates_options_123_1', 'gpld_dynamic_exceptions', 10, 3 );
function gpld_dynamic_exceptions( $options, $form, $field ) {
$date_values = array( '2016-09-04', '2016-09-16', '2016-09-22', '2016-09-26' ); // replace with your own method for getting a date
$max_date = time();
foreach( $date_values as $date_value ) {
$date_value = strtotime( $date_value );
if( $date_value > $max_date ) {
$options['exceptions'][] = date( 'm/d/Y', $date_value );
}
}
$options['exceptionMode'] = 'enable';
$options['disableAll'] = true;
return $options;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment