Last active
May 4, 2021 19:16
-
-
Save greathmaster/6263ba218ba1c6c59a794f012aa9cf7e to your computer and use it in GitHub Desktop.
Custom message for PMPro Email Confirmation Add On
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
function my_pmproec_pmpro_email_body($body, $email) | |
{ | |
//must be a confirmation email and checkout template | |
if(!empty($email->data['membership_id']) && pmproec_isEmailConfirmationLevel($email->data['membership_id']) && strpos($email->template, "checkout") !== false) | |
{ | |
//get user | |
$user = get_user_by("login", $email->data['user_login']); | |
$validated = $user->pmpro_email_confirmation_key; | |
$url = home_url("?ui=" . $user->ID . "&validate=" . $validated); | |
//need validation? | |
if(empty($validated) || $validated != "validated") | |
{ | |
//use validation_link substitute? | |
if(false === stripos($body, "!!validation_link!!")) | |
{ | |
//Modify this to your custom message | |
$body = "You must follow this link to confirm your email address <a href='" . $url . "'>" . $url . "</a><hr />" . $body; | |
$body = str_replace("Your membership account is now active.", "", $body); | |
} else | |
$body = str_ireplace("!!validation_link!!", $url, $body); | |
} | |
} | |
return $body; | |
} | |
function my_init() | |
{ | |
remove_filter("pmpro_email_body", "pmproec_pmpro_email_body", 10, 2); | |
add_filter("pmpro_email_body", "my_pmproec_pmpro_email_body", 10, 2); | |
} | |
add_action('init', 'my_init'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment