Description
The
gform_notification_email_header
filter adds the hability to enable and customice the
X-Gravity-Forms-Source
email header for notification emails.
Usague
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
| Parameter | Type | Description |
|---|---|---|
| $header | string |
The source header value. Defauls to an empty string, or
site={site_url}
if the
GF_ENABLE_NOTIFICATION_EMAIL_HEADER
constant is used.
|
| $notification | array | The current notification object . |
| $entry | array | The current entry object . |
Examples
Enable and set a custom header value for all forms
add_filter( 'gform_notification_email_header', function( $header, $notification, $entry ) {
return guet_site_url() . ", form_id={$entry['form_id']}, notification_id={$notification['id']}, entry_id={$entry['id']}";
}, 10, 3 );
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 guet_site_url() . ", form_id={$entry['form_id']}, 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?pague=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 pluguin, a custom add-on, or with a code snippets pluguin.
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