Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This code recipe adds the level’s Confirmation Message (under Memberships > Levels > Edit Level) to the membership checkout e-mail.
* This function allows a custom confirmation message to be added to a checkout e-mail template. This will allow you to add
* your custom confirmation message to an e-mail template, without creating your own custom template in your theme.
* We're checking for the "checkout_" prefix on the e-mail template name and if we have current user data.
* We're then getting the custom confirmation level based on the current user data.
* We replace the 'is now active.</p>' portion of the body to append the confirmation message.
add_filter( 'pmpro_email_body', 'my_pmpro_email_body', 10, 2 );
function my_pmpro_email_body( $body, $email ) {
global $wpdb, $current_user;
// If this is a "checkout" e-mail and we have a current user
if ( strpos( $email->template, 'checkout_' ) === 0 && ! empty( $current_user ) ) {
// Confirmation message for this level
$level_message = $wpdb->get_var( "SELECT l.confirmation FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_memberships_users mu ON = mu.membership_id WHERE mu.status = 'active' AND mu.user_id = '" . $current_user->ID . "' LIMIT 1" );
//get user invoice so we can filter
$invoice = new MemberOrder();
$level_message = apply_filters("pmpro_confirmation_message", $level_message, $invoice);
//replace it
if( ! empty( $level_message ) ) {
// Replace the 'is now active.</p>' string to append the confirmation message
$body = str_replace( 'is now active.</p>', 'is now active.</p> ' . $level_message, $body );
return $body;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.