Created
March 25, 2019 07:55
-
-
Save andrewlimaza/47633385bbee55ed9c3b6a1bf579bb0d to your computer and use it in GitHub Desktop.
Add first and last name variables to Paid Memberships Pro Emails
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
<?php | |
/** | |
* Adds !!first_name!! and !!last_name!! variables to be used with the Paid Memberships Pro Email Templates Add On. | |
* This data will be available for all Paid Memberships Pro emails. | |
* Add the below code to your PMPro Customizations Plugin and edit the email templates you want to add this to. | |
*/ | |
function add_first_and_last_name_to_pmpro_emails( $data, $email ) { | |
$user = get_user_by( 'email', $data['user_email'] ); | |
$first_name = get_user_meta( $user->ID, 'first_name', true ); | |
$last_name = get_user_meta( $user->ID, 'last_name', true ); | |
$data['first_name'] = $first_name; | |
$data['last_name'] = $last_name; | |
return $data; | |
} | |
add_filter( 'pmpro_email_data', 'add_first_and_last_name_to_pmpro_emails', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment