Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pbrocks/3598b26ed6aa075c65b532aa5b0bff19 to your computer and use it in GitHub Desktop.
Save pbrocks/3598b26ed6aa075c65b532aa5b0bff19 to your computer and use it in GitHub Desktop.
Add custom field to Paid Memberships Pro Checkout Email using Register Helper
<?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