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;
}