gform_after_email

gform_after_email

DescriptionUsageParametersExamples1. Retry sending2. Add note to entryPlacementSource Code

Description
Use this hook to perform actions after a user or admin notification has been sent.
Usage
1add_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.
12345678910add_action( 'gform_after_email', 'after_email', 10, 7 );function after_email( $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        }    }}
2. Add note to entry
This example shows how you can add a note to the entry.
1234add_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();    RGFormsModel::add_note( $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.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注