Created
November 15, 2023 00:24
-
-
Save MaximilianoRicoTabo/5fa14a882d4ebb98c0a9e8e295c51c45 to your computer and use it in GitHub Desktop.
filter email to avoid pending notification on pmpro approvals Add On for renewals
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 default emails to show that the user is active for renewals | |
*/ | |
function pmpro_email_filter( $email ) { | |
if( class_exists('PMPro_Approvals') ) { | |
$email_templates = array( 'checkout_paid', 'checkout_check', 'checkout_express' ); | |
//Get the user from the Email object. | |
$email_user = get_user_by( 'email', $email->email ); | |
//Determine if the user has been approved already for the email membership. | |
$approval_status = PMPro_Approvals::getUserApprovalStatus( $email_user->ID, $email->data['membership_id'] ); | |
// If it's the tempalte we're expecting and user has been approved, replace the text. | |
if ( in_array( $email->template, $email_templates ) && strtolower( $approval_status ) == "approved" ) { | |
//Change the body text to show pending by default. | |
$email->body = str_replace( 'Your membership account is now pending. You will be notified once your account has been approved/denied.', 'Your membership account is now active.', $email->body ); | |
} | |
return $email; | |
} | |
} | |
add_filter( 'pmpro_email_filter', 'pmpro_email_filter', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment