Created
July 6, 2020 09:53
-
-
Save andrewlimaza/a8bf60b450a6bcfce614ffe0f27ccb34 to your computer and use it in GitHub Desktop.
Add !!membership_level_name!! to all email templates for Paid Memberships Pro Email Template Add On.
This file contains 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 | |
/** | |
* Add attribute !!membership_level_name!! to all email templates for Paid Memberships Pro Email Templates Admin Editor. | |
* Follow this guide to add custom code to your WordPress site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_email_data($data, $email) { | |
if ( ! isset( $data['membership_level_name'] ) ) { | |
$user = get_user_by( 'email', $data['user_email'] ); | |
$level = pmpro_getMembershipLevelForUser( $user->ID ); | |
if ( isset( $level->name ) ) { | |
$data['membership_level_name'] = $level->name; | |
} else { | |
$data['membership_level_name'] = 'N/A'; | |
} | |
} | |
return $data; | |
} | |
add_filter( 'pmpro_email_data', 'my_pmpro_email_data', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment