Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Last active September 13, 2017 18:57
Show Gist options
  • Save strangerstudios/7f7b5865e9ab7974e4e50b202cb0500b to your computer and use it in GitHub Desktop.
Save strangerstudios/7f7b5865e9ab7974e4e50b202cb0500b to your computer and use it in GitHub Desktop.
Have Paid Memberships Pro admin checkout emails come from the customer.
/*
Have admin checkout emails come from the customer.
Add this code to a custom plugin.
*/
function pmpro_email_filter_checkout_from_users($email)
{
if(strpos($email->template, 'checkout') !== false) {
//get user info
$user = get_user_by('login', $email->data['user_login']);
//get from and from name. note that some SMTP servers (e.g. Google Mail)
//will ignore this and authmatically use the info from the Google account
$email->from = $user->user_email;
$email->fromname = $user->display_name;
//set reply to. even Google will set this
$email->headers[] = 'Reply-To: ' . $user->display_name . ' <' . $email->user_email . '>';
}
return $email;
}
add_action('pmpro_email_filter', 'pmpro_email_filter_checkout_from_users');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment