gform_after_email

Description

Use this hook to perform actions after a user or admin notification has been sent.

Usage

add_action( 'gform_after_email', 'your_function_name_here', 10, 12 );
add_action( 'gform_after_email', 'after_email', 10, 12 );

Parameters

  • $is_success bool

    Indicates whether the wp_mail function was able to successfully process the mail request without errors.

  • $to string

    Email address to which the message is being sent.

  • $subject string

    Email subject.

  • $message string

    Email body.

  • $headers array

    Email headers.

  • $attachments array

    Email attachment(s).

  • $message_format string

    Email format: text or html.

  • $from string

    From email.

  • $from_name string

    From name.

  • $bcc string

    Bcc email.

  • $reply_to string

    Reply to email.

  • $entry Entry Object

    The entry currently being processed or false if not available.

Examples

1. Retry sending

This example tries to send the email a second time if the original request was unsuccessful.

add_action( 'gform_after_email', function ( $is_success, $to, $subject, $message, $headers, $attachments, $message_format ) {
	if ( ! $is_success ) {
		//sending mail failed, try again one more time
		$try_again = wp_mail( $to, $subject, $message, $headers, $attachments );
		if ( ! $try_again ) {
			//still unable to send, do something...perhaps log the failure in a text file
		}
	}
}, 10, 7 );

2. Add note to entry

This example shows how you can add a note to the entry.

add_action( 'gform_after_email', function ( $is_success, $to, $subject, $message, $headers, $attachments, $message_format, $from, $from_name, $bcc, $reply_to, $entry ) {
	$current_user = wp_get_current_user();
	GFAPI::add_note( rgar( $entry, 'id' ), $current_user->ID, $current_user->display_name, 'the note to be added' );
}, 10, 12 );

Placement

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

Source Code

This action hook is located in GFCommon::send_email() in common.php.