Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ipokkel/bc37974a5b75527d8d47d67c70565d48 to your computer and use it in GitHub Desktop.
Save ipokkel/bc37974a5b75527d8d47d67c70565d48 to your computer and use it in GitHub Desktop.
<?php
/**
* Add !!instructions!! email variable data to the "add_member_added"
* email data if the payment method is "check".
*
* 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 add_instructions_to_pmpro_add_member_added_email_data( $data, $email ) {
if ( 'add_member_added' === $email->template ) {
$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;
if ( false !== strpos( $payment_method, 'check' ) ) {
$data['instructions'] = wpautop( pmpro_getOption( 'instructions' ) );
}
}
}
return $data;
}
add_filter( 'pmpro_email_data', 'add_instructions_to_pmpro_add_member_added_email_data', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment