Forked from andrewlimaza/adjust_pmpro_email_according_to_level.php
Created
November 3, 2020 09:52
-
-
Save MaryOJob/78290382bd285a9c1381e2f0bf68dce5 to your computer and use it in GitHub Desktop.
Change confirmation email contents in Paid Memberships Pro according to user level checkout.
This file contains hidden or 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 | |
/** | |
* Adjust email template according to user's level that they are checking out for. | |
* Add this code to your PMPro Customizations plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* For more information in customizing emails in Paid Memberships Pro visit - https://www.paidmembershipspro.com/documentation/member-communications/customizing-email-templates/ | |
* List of available email templates - https://www.paidmembershipspro.com/documentation/member-communications/list-of-pmpro-email-templates/ | |
*/ | |
function adjust_pmpro_email_according_to_level( $email ){ | |
//store email templates in an array. | |
$pmpro_email_templates = array( 'checkout_free', 'checkout_check', 'checkout_express', 'checkout_freetrial', 'checkout_paid', 'checkout_trial' ); //Email templates that possibly are sent out to user's when they checkout with PMPro. | |
//Get the level that the user is checking out for. | |
$level_for_email_change = $email->data['membership_id']; | |
if( in_array( $email->template, $pmpro_email_templates ) ){ | |
switch ( $level_for_email_change ) { | |
case '1': | |
$email->subject = 'This subject will change for user level 1'; | |
$email->body = 'This will change the user\'s body text for confirmation email for level 1'; | |
break; | |
case '3': | |
$email->subject = 'This subject will change for user level 3'; | |
$email->body = 'This will change the user\'s body text for confirmation email for level 3'; | |
break; | |
case '5': | |
$email->subject = 'This subject will change for user level 5'; | |
$email->body = 'This will change the user\'s body text for confirmation email for level 5'; | |
break; | |
default: | |
//leave empty to not do any changes to email. | |
break; | |
} | |
} | |
return $email; | |
} | |
add_filter( 'pmpro_email_filter', 'adjust_pmpro_email_according_to_level' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment