Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This gist changes the output of the checkout email based on the member's level.
<?php
/**
* Change content of Checkout email based on membership level.
*
* @param string $body The contents of the email is a string of text that you can adjust here as you see fit or pull from another custom function.
* @param object $email This is the php object from which we extracting the appropriate level and to which we'll add the new email content.
* @return string Whichever condition applies in the function below will determine what string is supplied to the email object. If none of the conditions are met, the return string will be the original message content.
*/
function pmpro_adjust_email_content_to_level_checkout( $body, $email ) {
if ( 0 === strpos( $email->template, 'checkout_' ) ) {
if ( 1 === intval( $email->data['membership_id'] ) ) {
$body = 'Email content for Level 1';
}
if ( 2 === intval( $email->data['membership_id'] ) ) {
$body = 'The content of email for Level 2, certainly different than above';
}
if ( 3 === intval( $email->data['membership_id'] ) ) {
$body = 'Email content for Level 3';
}
if ( 4 === intval( $email->data['membership_id'] ) ) {
$body = 'Email content for Level 4';
}
}
return $body;
}
add_filter( 'pmpro_email_body', 'pmpro_adjust_email_content_to_level_checkout', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment