Documentation » Action Hooks

groundhogg/email/after_send

Published · Last updated

Fires after an Email object has finished its send attempt, whether it succeeded or failed.

do_action( 'groundhogg/email/after_send', $email );

You will receive the Email object.

Example

add_action( 'groundhogg/email/after_send', 'my_extension_record_send' );

/**
 * Record every email send in a custom analytics table.
 *
 * @param \Groundhogg\Email $email
 *
 * @return void
 */
function my_extension_record_send( $email ) {
    $contact = $email->get_contact();

    my_extension_log_send( [
        'email_id'   => $email->get_id(),
        'contact_id' => $contact ? $contact->get_id() : 0,
        'subject'    => $email->get_subject_line(),
        'sent_at'    => current_time( 'mysql' ),
    ] );
}