Forked from andrewlimaza/custom-field-register-helper-checkout-email.php
Last active
April 9, 2018 13:17
-
-
Save pbrocks/3598b26ed6aa075c65b532aa5b0bff19 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 + strict comparison | |
if ( false !== strpos( $email->template, 'checkout' ) ) { | |
global $current_user; | |
$company_name = get_user_meta( $current_user->ID, 'company_name', true ); | |
$body = str_replace( '!!company_name!!', $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