Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaryOJob/0bf8426be5cacee64e6c80d06855191a to your computer and use it in GitHub Desktop.
Save MaryOJob/0bf8426be5cacee64e6c80d06855191a to your computer and use it in GitHub Desktop.
Add first name variable to Paid Memberships Pro Emails
<?php // do not copy this line
/**
* Adds !!first_name!! variable to be used with the Paid Memberships Pro Email Templates.
* This data will be available for all Paid Memberships Pro emails.
* Add the below code to your PMPro Customizations Plugin: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* And edit the email templates you want to add this to
*/
function add_first_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 ); // uncomment to add the last name if needed
$data['first_name'] = $first_name;
// $data['last_name'] = $last_name; // uncomment to add the last name if needed
return $data;
}
add_filter( 'pmpro_email_data', 'add_first_name_to_pmpro_emails', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment