Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active August 21, 2023 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ipokkel/e7eab716cb839c2a0792ecee6e41c4b9 to your computer and use it in GitHub Desktop.
Save ipokkel/e7eab716cb839c2a0792ecee6e41c4b9 to your computer and use it in GitHub Desktop.
Create a custom confirmation with a custom message if the user still requires to confirm their email
<?php
/**
* This recipe changes the default confirmation message when a user checks out.
*
* This is adapted from https://gist.github.com/femiyb/253535512d0df7165d4cd7f9716c25f5
* https://www.paidmembershipspro.com/custom-confirmation-page-content/
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
remove_filter( 'pmpro_confirmation_message', 'pmpro_pmpro_confirmation_message' );
// add new confirmation text
function my_pmpro_confirmation_message( $message ) {
global $current_user;
$message = '';
// Set default
$message .= '<p>Thank you for choosing the <strong>' . pmpro_getMembershipLevelForUser( $current_user->ID )->name . '</strong> membership.</p>';
//Custom message if email confirmation level and user's email not confirmed.
if ( function_exists( 'pmproec_isEmailConfirmationLevel') && 0 != intval( pmpro_getMembershipLevelForUser( $current_user->ID ) ) && pmproec_isEmailConfirmationLevel( intval( pmpro_getMembershipLevelForUser( $current_user->ID )->ID ) ) ) {
if ( $current_user->pmpro_email_confirmation_key != 'validated' ) {
$message .= '<p>We sent an email to <strong>' . $current_user->user_email . '</strong>. Please check your inbox and confirm your email. Once it’s done you will be able to activate your <strong>' . pmpro_getMembershipLevelForUser( $current_user->ID )->name . '</strong> membership.</p>';
}
}
return $message;
}
add_filter( 'pmpro_confirmation_message', 'my_pmpro_confirmation_message', 20, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment