gform_sendgrid_email

Description

Allows the email being sent by SendGrid to be modified.

Usage

The following would apply to all forms:

add_filter( 'gform_sendgrid_email', 'your_function_name', 10, 5 );

To target a specific form, append the form id to the hook name. (format: gform_sendgrid_email_FORMID)

add_filter( 'gform_sendgrid_email_1', 'your_function_name', 10, 5 );

To target a specific feed for a form, append the form id and feed id to the hook name. (format: gform_sendgrid_email_FORMID_FEEDID)

add_filter( 'gform_sendgrid_email_1_4', 'your_function_name', 10, 5 );

Parameters

  • $sendgrid_email array

    The SendGrid email arguments.

  • $email array

    The original email details.

  • $message_format string

    The message format, html or text.

  • $notification Notification Object

    The Notification object.

  • $entry Entry Object

    The current entry.

Examples

add_filter( 'gform_sendgrid_email', 'change_sendgrid_email', 10, 5 );
function change_sendgrid_email( $sendgrid_email, $email, $message_format, $notification, $entry ){
        //add a CC email address
	$sendgrid_email['personalizations'][0]['cc'][0]['email'] = 'testingcc@rocketgenius.com';
	return $sendgrid_email;
}

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in SendGrid v1. Added $entry parameter in v2.

Source Code

This filter is located in GF_SendGrid::maybe_send_email() in gravityformssendgrid/class-gf-sendgrid.php.