spivurno
3/8/2020 - 5:22 PM

Gravity Wiz // Gravity Forms // Email Header to Identify Notification Source

<?php
/**
 * Gravity Wiz // Gravity Forms // Email Header to Identify Notification Source
 *
 * You've installed Gravity Forms on a ton of sites and now you're getting a ton of notifications. The problem is there
 * is no clear indicator which site is sending the notification. How frustrating!
 *
 * This simple plugin automatically adds a custom header that identifies the URL that generated the Gravity Forms notification. 
 * This is most useful when installed as an MU plugin at the start of development on each site.
 *
 * @version  1.0
 * @author   David Smith <david@gravitywiz.com>
 * @license  GPL-2.0+
 * @link     http://gravitywiz.com/
 *
 * Plugin Name:  Gravity Forms - Email Header: Notification Source
 * Plugin URI:   http://gravitywiz.com/
 * Description:  Add a custom email header to identify the URL that generated the Gravity Forms notification.
 * Author:       Gravity Wiz
 * Version:      1.0
 * Author URI:   http://gravitywiz.com
 */
add_filter( 'gform_pre_send_email', function( $email ) {
	$email['headers']['X-gravity-forms-source'] = sprintf( 'X-gravity-forms-source: %s', GFFormsModel::get_current_page_url() );
	return $email;
} );