Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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