Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created March 25, 2019 07:55
Show Gist options
  • Save andrewlimaza/47633385bbee55ed9c3b6a1bf579bb0d to your computer and use it in GitHub Desktop.
Save andrewlimaza/47633385bbee55ed9c3b6a1bf579bb0d to your computer and use it in GitHub Desktop.
Add first and last name variables to Paid Memberships Pro Emails
<?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