Forked from pbrocks/pmpro-adjust-email-content-to-level-checkout.php
Last active
March 28, 2019 19:17
-
-
Save LMNTL/5af79bcbf58a364b0eba42e2e5fb9eea to your computer and use it in GitHub Desktop.
This gist changes the subject line of the checkout email based on the member's level. - based on https://gist.github.com/pbrocks/abe099df6a462cb2353240af63a53959
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change subject line of Checkout email based on membership level. | |
* | |
* @param string $subject The email's subject 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 subject. | |
*/ | |
function pmpro_adjust_email_subject_to_level_checkout( $subject, $email ) { | |
if ( 0 === strpos( $email->template, 'checkout_' ) ) { | |
if ( 1 === intval( $email->data['membership_id'] ) ) { | |
$subject = 'Subject line for Level 1'; | |
} | |
if ( 2 === intval( $email->data['membership_id'] ) ) { | |
$subject = 'Subject line of email for Level 2, certainly different than above'; | |
} | |
if ( 3 === intval( $email->data['membership_id'] ) ) { | |
$subject = 'Subject line for Level 3'; | |
} | |
if ( 4 === intval( $email->data['membership_id'] ) ) { | |
$subject = 'Subject line for Level 4'; | |
} | |
} | |
return $subject; | |
} | |
add_filter( 'pmpro_email_subject', 'pmpro_adjust_email_subject_to_level_checkout', 30, 2 ); //setting the priority to 30 to make sure it runs after most other filters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment