Send Notifications to Merge Tags

Use any merge tag in your notification’s “Send to Email” setting.

Code

Filename: gw-send-notifications-to-merge-tags.php

<?php
/**
 * Gravity Wiz // Gravity Forms // Send Notifications to Merge Tags
 * https://gravitywiz.com/
 *
 * Plugin Name:  Gravity Forms Send Notifications to Merge Tags
 * Plugin URI:   https://gravitywiz.com/
 * Description:  Use any merge tag in your notification's "Send to Email" setting.
 * Author:       Gravity Wiz
 * Version:      1.0
 * Author URI:   https://gravitywiz.com/
 *
 * By default, Gravity Forms Notifications only support Email fields and a pre-population merge tags. In some cases, you
 * may have email values in non-Email fields (i.e. populating a Drop Down field with users where their email as the
 * value).
 *
 * This plugin will process *any* merge tag used in your notification's "Send to Email" setting.
 *
 * ![Example](https://gwiz.io/34ZzYW9)
 */
add_filter( 'gform_notification', function( $notification, $form, $entry ) {
	$notification['to'] = GFCommon::replace_variables( $notification['to'], $form, $entry, false, false, false, 'text' );
	return $notification;
}, 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.