groundhogg/email/subject

πŸ“… Published on

πŸ“ Last updated

Documentation

Β»

Filter Hooks

Β»

groundhogg/email/subject

Filters the subject line of an email just before it is sent, after merge tags have been processed.

apply_filters( 'groundhogg/email/subject', $subject, $email, $contact );

You will receive the processed subject string, the Email object, and the recipient Contact object.

Example

add_filter( 'groundhogg/email/subject', 'my_extension_personalise_subject', 10, 3 );

/**
 * Prepend the contact's company name to the subject for B2B sends.
 *
 * @param string               $subject
 * @param \Groundhogg\Email   $email
 * @param \Groundhogg\Contact $contact
 *
 * @return string
 */
function my_extension_personalise_subject( $subject, $email, $contact ) {
    $company = $contact->get_company();

    if ( $company ) {
        return '[' . $company . '] ' . $subject;
    }

    return $subject;
}

Was this helpful?

Let us know if this document answered your question. That’s the only way we can improve.