Sending Notifications with the GFAPI

Introduction

The GFAPI::send_notifications() method is used to send notifications for a specific event and the given form and entry.

Source Code

public static function send_notifications( $form, $entry, $event = 'form_submission', $data = array() ) {}

This method is located in /includes/api.php.

Parameters

ParamTypeDescription
$formarrayThe Form Object.
$entryarrayThe Entry Object.
$eventstringOptional.
Default: form_submission
The event that is triggering sending of the notifications.
Custom events can be listed in the event drop down on the edit notification page by using the gform_notification_events filter.
$dataarrayOptional.
Default: an empty array.
An array of data that can be used in the notifcations via the generic {object:property} merge tag.

Returns

An array containing the IDs of the processed notifications.

Usage Examples

User Registered

This example shows how you can trigger the sending of notifications for the User is registered (user_registered) event.

GFAPI::send_notifications( $form, $entry, 'user_registered' );

Form Submission

This example shows how you can trigger the sending of notifications for the default form submission event.

GFAPI::send_notifications( $form, $entry );

Custom event and merge tag data

This example shows how you can trigger the sending of notifications for a custom event and pass along custom merge tag data. In this case the merge tag {foo:bar} would output baz.

$data = array(
    'foo' => array(
        'bar' => 'baz',
    )
);
GFAPI::send_notifications( $form, $entry, 'my_custom_event', $data );