Personalize the referral invite sender name

Prefix the normal sender name with the advocate’s name when it is available.

Developer note:

Add custom PHP in a small custom plugin or child theme, and test it on a staging site before production. This example requires ongoing maintenance when extension APIs change.

functions.php

<?php

add_filter( 'automatewoo/referrals/invite_email/mailer', 'my_store_referral_invite_sender', 10, 2 );

/**
 * Personalize the referral invite sender name.
 *
 * @param AutomateWoo\Mailer                 $mailer Mailer.
 * @param AutomateWoo\Referrals\Invite_Email $invite Invite email.
 * @return AutomateWoo\Mailer
 */
function my_store_referral_invite_sender( $mailer, $invite ) {
	$advocate_name = $invite->advocate->get_name();

	if ( $advocate_name ) {
		$mailer->from_name = sprintf(
			/* translators: 1: advocate name, 2: store sender name. */
			__( '%1$s via %2$s', 'my-store' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
			$advocate_name,
			$mailer->get_from_name()
		);
	}

	return $mailer;
}

Related Products

Offer Royal Mail shipping rates to your customers.

Get shipping rates from the Canada Post Ratings API which handles both domestic and international parcels.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.