Notifications Object

Introduction

The Notifications object is an associative array containing the properties for all the email notifications which exist for a form. On a default installation when a new form is created a single notification, named Admin Notification, is created for the form. There is no limit to the number of additional notifications you can create.

See the Configuring Notifications In Gravity Forms article for a tutorial showing how you can configure notifications in the admin.

$form['notifications'] = array(
    '558a90489ced3' => array(
        'isActive'          => true,
        'id'                => '558a90489ced3',
        'name'              => 'Admin Notification',
        'event'             => 'form_submission',
        'to'                => '{admin_email}',
        'toType'            => 'email',
        'subject'           => 'New submission from {form_title}',
        'message'           => '{all_fields}',
        'from'              => '{admin_email}',
        'disableAutoformat' => false,
        'enableAttachments' => false
    ),
    '558a905b98b18' => array(
        'isActive'          => true,
        'id'                => '558a905b98b18',
        'name'              => 'User Notification',
        'event'             => 'form_submission',
        'to'                => '2',
        'toType'            => 'field',
        'subject'           => 'Thanks for your form submission',
        'message'           => '{all_fields}',
        'from'              => '{admin_email}',
        'conditionalLogic'  => array(
            'actionType' => 'show',
            'logicType'  => 'all',
            'rules'      => array(
                array(
                    'fieldId'  => '3',
                    'operator' => 'is',
                    'value'    => 'Email me a copy',
                ),
            ),
        ),
        'disableAutoformat' => false,
        'enableAttachments' => false
    ),
);

Usage

The notifications are part of the Form Object and so are most commonly accessed like so:

$notifications = rgar( $form, 'notifications' );

Notification Properties

PropTypeDescription
isActivebooleanIndicates the notification status, active or inactive.
Default: true
idstringThe notification ID.
A 13 character unique ID generated by the PHP uniqid function.
namestringThe notification name.
servicestringThe name of the service to be used when sending this notification.
Default: wordpress
eventstringThe name of the event the notification should be sent on.
Default: form_submission
tointeger|stringThe ID of an email field, an email address or merge tag to be used as the email to address.
toTypestringIdentifies what to use for the notification to.
Possible values: email, field, routing, or hidden
bccstringThe email or merge tags to be used as the email bcc address.
subjectstringThe email subject line.
Merge tags supported.
messagestringThe email body/content.
Merge tags supported.
fromstringThe email or merge tag to be used as the email from address.
fromNamestringThe text or merge tag to be used as the email from name.
replyTostringThe email or merge tags to be used as the email reply to address.
routingnull|arrayAn indexed array containing the routing rules.
See Routing Rule Properties properties for each rule.
conditionalLogicnull|arrayAn associative array containing the conditional logic rules.
See the Conditional Logic Object for more details.
disableAutoformatbooleanDetermines if the email message should be formatted so that paragraphs are automatically added for new lines.
Default: false (auto-formatting enabled)
enableAttachmentsbooleanDetermines if files uploaded on the form should be attached to the notification email when sent.

Routing Rule Properties

array(
    'fieldId'  => '3',
    'operator' => 'is',
    'value'    => 'Email me a copy',
    'email'    => '{admin_email}',
)
PropTypeDescription
fieldIdinteger|stringThe target field ID.
The field that will have it’s value compared with value to determine if this rule is a match.
operatorstringOperator to be used when evaluating this rule.
Possible values: is, isnot, >, <, contains, starts_with, or ends_with.
valuestringThe value to compare with the field specified by fieldId.
emailstringThe email or merge tag to be used as the email To address if this rule is a match.

Notification JSON

This example shows how a basic notification array would look when formatted as JSON for use by the Gravity Forms CLI Add-On.

{
    "id": "5acf8e9cf2b40",
    "to": "{admin_email}",
    "name": "Admin Notification",
    "event": "form_submission",
    "toType": "email",
    "subject": "New submission from {form_title}",
    "message": "{all_fields}"
}