• Home
  • Pricing
  • Free Resources
  • About
  • Docs
  • Support
  • Account

Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Pricing
  • Blog
    • Free Resources
    • About
  • Support
    • Docs
    • Support
    • Account

gpns_schedule_timestamp

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Set the notification’s time to a custom time
      1. Send notification on the last day of every month
      2. Send notification at the beginning of the next work week
  5. Since

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

Set the notification’s time to a custom time

Use the examples below to set a notification’s time to a timestamp generated by a string.

The configuration of the notification needs to have any Schedule Type other than “Immediate” for these examples to take effect.

Send notification on the last day of every month

<?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 Perks

  • GF Address Autocomplete
  • GF Advanced Calculations
  • GF Advanced Phone Field
  • GF Advanced Save & Continue
  • GF Auto List Field
  • GF Auto Login
  • GF Better User Activation
  • GF Blocklist
  • 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 Entry Blocks
  • GF Expand Textareas
  • GF File Renamer
  • GF File Upload Pro
  • GF Google Sheets
  • GF Inventory
  • GF Limit Checkboxes
  • GF Limit Choices
  • 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 PayPal One-time Fee
  • GF Placeholder
  • 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 Terms Of Service
  • GF Unique ID
  • GF Word Count

Copyright © 2023 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Terms & Conditions of Use
  • Privacy Policy
  • Cookies Policy