Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewlimaza/6f258fbbc7cd81145fd05d0f82e188a7 to your computer and use it in GitHub Desktop.
Save andrewlimaza/6f258fbbc7cd81145fd05d0f82e188a7 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
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