Last active
March 8, 2022 20:00
-
-
Save claygriffiths/48d8f31176f65cf48b1379a76813d504 to your computer and use it in GitHub Desktop.
GP Notification Scheduler: Set Recurring Schedule to Every 6 Months
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gravity Perks // GP Notification Scheduler // Set Recurring Schedule to Every 6 Months | |
* https://gravitywiz.com/documentation/gravity-forms-notification-scheduler | |
* | |
* Instructions: | |
* * Install snippet per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ | |
* * Update $form_id, $notification_id, and if required, $desired_time | |
*/ | |
add_filter( 'gpns_schedule_timestamp', function ( $timestamp, $notification, $entry, $is_recurring, $current_time ) { | |
$form_id = 6; | |
$notification_id = '61f43ccb47dfd'; | |
// See https://www.php.net/manual/en/datetime.formats.php for supported date/time formats. | |
$desired_time = '+6 months 12:00 PM'; | |
if ( (int) $entry['form_id'] !== (int) $form_id || $notification['id'] !== $notification_id ) { | |
return $timestamp; | |
} | |
/* Only change the timestamp if scheduling the recurring notification. */ | |
if ( ! $is_recurring ) { | |
return $timestamp; | |
} | |
$local_timestamp = date( 'Y-m-d H:i:s', strtotime( $desired_time ) ); | |
$utc_timestamp = strtotime( get_gmt_from_date( $local_timestamp ) ); | |
return $utc_timestamp; | |
}, 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment