Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ipokkel/404e40b838390127d2643627381179fc to your computer and use it in GitHub Desktop.
Save ipokkel/404e40b838390127d2643627381179fc to your computer and use it in GitHub Desktop.
PMPro add custom fields to email
<?php
/**
* This recipe Adds !!company!! as an available variable for use in Paid Memberships Pro emails.
* When the variable is empty it will display nothing instead of the !!company!! email variable
*
* Notice the array key does not include the !!s
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_email_data( $data, $email ) {
global $current_user;
$company = get_user_meta( $current_user->ID, 'company', false );
if ( empty( $company ) ) {
$company = ''; // display nothing for email ariable !!company!! if empty.
}
$data['company'] = $company;
return $data;
}
add_filter( 'pmpro_email_data', 'my_pmpro_email_data', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment