Pass email API
Send wallet pass links programmatically with EPC_Pass_Email.
Send for a pass row
PHP
$pass = EPC_DB::get_pass( 'memberpress', $subscription_id );
$result = EPC_Pass_Email::send_for_pass_row( $pass, array(
'to' => '[email protected]',
'subject' => 'Your pass',
'body' => 'Link: {pass_link}',
'module_label' => 'MemberPress',
) );
if ( is_wp_error( $result ) ) {
// epc_no_pass_link, epc_no_recipient, epc_mail_failed
}
Send by module + source id
PHP
EPC_Pass_Email::send_for_source( 'woocommerce-subscriptions', $subscription_id );
Disable auto send
PHP
add_filter( 'epc_pass_email_auto_send', '__return_false' );
HTML email example
PHP
add_filter( 'epc_pass_email_headers', function ( $headers ) {
return array( 'Content-Type: text/html; charset=UTF-8' );
} );
add_filter( 'epc_pass_email_body', function ( $body, $pass_row, $replacements ) {
$link = esc_url( $replacements['pass_link'] );
return '<p>Hi ' . esc_html( $replacements['user_first_name'] ) . ',</p>'
. '<p><a href="' . $link . '">Add to wallet</a></p>';
}, 10, 3 );
Hook on pass created
PHP
add_action( 'epc_pass_created', function ( $slug, $source_id, $pass_row ) {
// Custom delivery: SMS, CRM, etc.
}, 10, 3 );