gpns_schedule_timestamp
Description
Filter the timestamp (Unix epoch) used to schedule a notification
Usage
Apply to all applicable fields on all forms.
add_filter( 'gpns_schedule_timestamp', 'my_custom_function' );
Apply to all applicable fields on a specific form.
add_filter( 'gpns_schedule_timestamp_FORMID', 'my_custom_function' );
Parameters
schedule_datetime int
Unix epoch (seconds) that will be used as the time of when the notification should send.
notification array
The notification.
entry array
The current entry.
is_recurring boolean
Whether the notification is being scheduled as a recurring notification.
current_time int
The current server Unix epoch timestamp.
Examples
Send notification on the last day of every month
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
* Gravity Perks // Notification Scheduler // Send Notification on the Last Day of Every Month
* https://gravitywiz.com/documentation/gravity-forms-notification-scheduler/
*/
add_filter( 'gpns_schedule_timestamp', function ( $timestamp, $notification, $entry, $is_recurring, $current_time ) {
// Update "123" to the form ID.
$form_id = 123;
// Update "1a23bc456def7" to the notification ID.
$notification_id = '1a23bc456def7';
// See https://www.php.net/manual/en/datetime.formats.php for supported date/time formats.
if ( $is_recurring ) { // If the notification has just been triggered to send and the next recurring notification is being scheduled (if repeat is enabled)
$desired_time = 'last day of next month 12:00 PM';
} else {
$desired_time = 'last day of this month 12:00 PM';
}
if ( (int) $entry['form_id'] !== (int) $form_id || $notification['id'] !== $notification_id ) {
return $timestamp;
}
$local_timestamp = gmdate( 'Y-m-d H:i:s', strtotime( $desired_time ) );
$utc_timestamp = strtotime( get_gmt_from_date( $local_timestamp ) );
return $utc_timestamp;
}, 10, 5 );
Send notification at the beginning of the next work week
<?php
/**
* Gravity Perks // Notification Scheduler // Send Notification at the Beginning of the Next Work Week
* https://gravitywiz.com/documentation/gravity-forms-notification-scheduler/
*/
add_filter( 'gpns_schedule_timestamp', function ( $timestamp, $notification, $entry, $is_recurring, $current_time ) {
// See https://www.php.net/manual/en/datetime.formats.php for supported date/time formats.
$desired_time = 'next monday 12:00 PM';
// Update "123" to the form ID.
$form_id = 123;
// Update "1a23bc456def7" to the notificaiton ID.
$notification_id = '1a23bc456def7';
if ( (int) $entry['form_id'] !== (int) $form_id || $notification['id'] !== $notification_id ) {
return $timestamp;
}
$local_timestamp = gmdate( 'Y-m-d H:i:s', strtotime( $desired_time ) );
$utc_timestamp = strtotime( get_gmt_from_date( $local_timestamp ) );
return $utc_timestamp;
}, 10, 5 );
Since
This filter is available since Gravity Forms Notification Scheduler 1.0.2.
All Connections
All Perks
- GF Address Autocomplete
- GF Advanced Calculations
- GF Advanced Phone Field
- GF Advanced Save & Continue
- GF Advanced Select
- GF Auto List Field
- GF Auto Login
- GF Better User Activation
- GF Blocklist
- GF Bookings
- GF Conditional Logic Dates
- GF Conditional Pricing
- GF Copy Cat
- GF Date Time Calculator
- GF Disable Entry Creation
- GF Easy Passthrough
- GF eCommerce Fields
- GF Email Users
- GF Email Validator
- GF Entry Blocks
- GF Expand Textareas
- GF File Renamer
- GF File Upload Pro
- GF Inventory
- GF Limit Checkboxes
- GF Limit Dates
- GF Limit Submissions
- GF Live Preview
- GF Media Library
- GF Multi-Page Navigation
- GF Nested Forms
- GF Notification Scheduler
- GF Page Transitions
- GF Pay Per Word
- GF Populate Anything
- GF Post Content Merge Tags
- GF Preview Submission
- GF Price Range
- GF QR Code
- GF Randomizer
- GF Read Only
- GF Reload Form
- GF Submit to Access
- GF Terms Of Service
- GF Unique ID
- GF Word Count