Forked from travislima/pmpro-add-custom-fields-to-email.php
Last active
November 4, 2020 14:52
-
-
Save ipokkel/404e40b838390127d2643627381179fc to your computer and use it in GitHub Desktop.
PMPro add custom fields to email
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 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