Last active
May 28, 2019 05:30
-
-
Save andrewlimaza/6f258fbbc7cd81145fd05d0f82e188a7 to your computer and use it in GitHub Desktop.
Add custom field to Paid Memberships Pro Checkout Email using Register Helper
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 | |
/** | |
* This will check for !!company_name!! in the emails body and replace it with the 'company_name' metadata (created by Register Helper). | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_email_body( $body, $email ) { | |
//only checkout emails | |
if ( false !== strpos( $email->template, "checkout" ) ) { | |
$user = get_user_by( 'email', $email->data['user_email'] ); | |
$company_name = get_user_meta( $user->ID, 'company', true ); | |
$body = str_replace( '!!company!!', $company_name, $body ); | |
} | |
return $body; | |
} | |
add_filter( "pmpro_email_body", "my_pmpro_email_body", 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment