Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Overwrite the modified email confirmation message from PMPro Email Confirmation Add On.
<?php
// Copy from below here...
/*
* Overwrite the modified email confirmation message from PMPro Email Confirmation Add On.
*/
function my_pmproec_pmpro_confirmation_message( $message ) {
remove_filter( 'pmpro_confirmation_message', 'pmproec_pmpro_confirmation_message' );
//must be an email confirmation level
if(!empty($_REQUEST['level']) && pmproec_isEmailConfirmationLevel(intval($_REQUEST['level'])))
{
global $current_user;
if($current_user->pmpro_email_confirmation_key != "validated")
{
$message = str_replace( "is now active", esc_html__( "will be activated as soon as you confirm your email address", "pmpro-email-confirmation" ) . ". <strong>" . sprintf( esc_html__( "Important! You must click on the confirmation URL sent to %s before you gain full access to your membership", "pmpro-email-confirmation" ), $current_user->user_email ) . "</strong>", $message );
}
}
return $message;
}
add_filter( "pmpro_confirmation_message", "my_pmproec_pmpro_confirmation_message", 9 );
/*
* Overwrite the message for users without access from PMPro Email Confirmation Add On.
*/
function my_pmproec_pmpro_text_filter($text){
remove_filter("pmpro_non_member_text_filter", "pmproec_pmpro_text_filter");
remove_filter("pmpro_not_logged_in_text_filter", "pmproec_pmpro_text_filter");
global $wpdb, $current_user, $post;
if(!empty($post) && !empty($current_user->ID)) {
//does this user have a level that requires confirmation?
$user_membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
if(!empty($user_membership_level) && pmproec_isEmailConfirmationLevel($user_membership_level->id)) {
$validated = $current_user->pmpro_email_confirmation_key;
//need validation?
if( ! empty($validated) && $validated != "validated" ) {
$text = '<p>' . sprintf( esc_html__('Your %s membership will be activated as soon as you confirm your email address', 'pmpro-email-confirmation'), $user_membership_level->name) . '.<strong> ' . sprintf( esc_html__('Important! You must click on the confirmation URL sent to %s before you gain full access to your membership', 'pmpro-email-confirmation'), $current_user->user_email) . '</strong>.</p>';
}
}
}
return $text;
}
add_filter("pmpro_non_member_text_filter", "my_pmproec_pmpro_text_filter", 9);
add_filter("pmpro_not_logged_in_text_filter", "my_pmproec_pmpro_text_filter", 9);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment