Skip to content

Instantly share code, notes, and snippets.

@claygriffiths
Last active March 8, 2022 20:00
Show Gist options
  • Select an option

  • Save claygriffiths/48d8f31176f65cf48b1379a76813d504 to your computer and use it in GitHub Desktop.

Select an option

Save claygriffiths/48d8f31176f65cf48b1379a76813d504 to your computer and use it in GitHub Desktop.

Revisions

  1. claygriffiths revised this gist Mar 8, 2022. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions gpns-custom-recurring-schedule.php
    Original file line number Diff line number Diff line change
    @@ -11,17 +11,17 @@
    $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';
    // 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;
    }
    /* 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 ) );
  2. claygriffiths revised this gist Mar 8, 2022. No changes.
  3. claygriffiths created this gist Mar 8, 2022.
    30 changes: 30 additions & 0 deletions gpns-custom-recurring-schedule.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <?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 );