Forked from ipokkel/add-payment-method-to-pmpro-emails.php
Last active
May 22, 2025 10:26
-
-
Save JarrydLong/4ae798023ebb23d36faf5bae0dbcdeef to your computer and use it in GitHub Desktop.
Adds payment method variable to Paid Memberships Pro emails that can be included using the Paid Memberships Pro Email Templates Add On
This file contains hidden or 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 | |
/** | |
* Adds !!payment_method!! variable to be used with the | |
* Paid Memberships Pro Email Templates Add On. | |
* This data will be available for all Paid Memberships Pro emails. | |
* Add the below code to your PMPro Customizations Plugin and | |
* edit the email templates you want to add this to. | |
*/ | |
function add_payment_method_to_pmpro_emails( $data, $email ) { | |
$data['payment_method'] = 'N/A'; | |
$invoice_id = null; | |
// Get payment method from invoice | |
if ( isset( $data['invoice_id'] ) ) { | |
$invoice_id = $data['invoice_id']; | |
} | |
if ( ! empty( $invoice_id ) ) { | |
$invoice = new MemberOrder( $invoice_id ); | |
$payment_method = $invoice->gateway; | |
$data['payment_method'] = ucwords( $payment_method ); | |
} | |
return $data; | |
} | |
add_filter( 'pmpro_email_data', 'add_payment_method_to_pmpro_emails', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment