Hi,
I have just added 2 hooks before and after mail sent, that will be available after next version release:
do_action( "lrm/mail/before_sent", $mail_key );
$mail_sent = wp_mail( $to, $subject, $mail_body );
do_action( "lrm/mail/after_sent", $mail_key );
So you can use “wp_mail” filter:
/**
* Filters the wp_mail() arguments.
*
* @since 2.2.0
*
* @param array $args A compacted array of wp_mail() arguments, including the "to" email,
* subject, message, headers, and attachments values.
*/
$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
Example:
add_action("lrm/mail/before_sent", function() {
add_filter("wp_mail", function($atts) {
if ( !function_exists("wc_locate_template") ) { return $atts; }
ob_start();
wc_locate_template( "woocommerce/templates/emails/email-header.php" );
echo $atts['message'];
wc_locate_template( "woocommerce/templates/emails/email-footer.php" );
$atts['message'] = ob_get_clean();
return $atts;
});
});
-
This reply was modified 6 years, 2 months ago by Max K.
-
This reply was modified 6 years, 2 months ago by Max K.