gform_notification_email_header

Description

The gform_notification_email_header filter adds the ability to enable and customize the X-Gravity-Forms-Source email header for notification emails.

Usage

Apply to all notifications for a form.

add_filter( 'gform_notification_email_header_FORM_ID', 'your_custom_function', 10, 3);

Apply to a specific notification for a form.

add_filter( 'gform_notification_email_header_FORM_ID_NOTIFICATION_ID', 'your_custom_function', 10, 3);

Parameters

ParameterTypeDescription
$headerstringThe source header value. Defaults to `site={site_url}`
$notificationarrayThe current notification object.
$entryarrayThe current entry object.

Examples

Enable and set a custom header value on a form for a specific notification.

// Replace 123 with your Form ID and 51794abf1f0d2 with your Notification ID.
add_filter( 'gform_notification_email_header_123_51794abf1f0d2', function( $header, $notification, $entry ) {
    return get_site_url() . ", notification_id={$notification['id']}, entry_id={$entry['id']}";
}, 10, 3 );

Finding your Notification ID

When editing your notification, you will find the notification ID in the browser address bar at the very end after the ?nid= parameter:

example.com/wp-admin/admin.php?page=gf_edit_forms&view=settings&subview=notification&id=95
&orderby=name&order=desc&nid=51794abf1f0d2

The notification ID in this example is 51794abf1f0d2

Disable email header value on a form for all notifications.

// Replace 123 with your Form ID.
add_filter( 'gform_notification_email_header_123', '__return_empty_string' );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in common.php

Since

This filter was added in Gravity Forms 2.9.13