Again-Again: MEC Confirmation Emails*****

This one was closed again, without any solution…:

MEC Confirmation EmailsMEC Confirmation Emails

Please continue…

Thanks
Christian

Hey Christian,

Please try updating to the latest version of MEC.

Thanks.

…we did, the last weeks again and again…

regards,
cy.

Hey @cyrock,

Please try adding the following code snippet to your child theme’s functions.php just to see if it fixes the issue on your end. We’ll then report this to the MEC authors.

// Hook into WordPress's default wp_mail filter to fix MEC email formatting issues
add_filter('wp_mail', 'fix_mec_email_paragraph_tags');

function fix_mec_email_paragraph_tags($args) {
    // Check if the email content belongs to MEC by looking for its unique template wrapper class
    if (isset($args['message']) && strpos($args['message'], 'class="wn-wrapper"') !== false) {
        // Extract the content inside the "wn-wrapper" container, apply wpautop to it, and re-insert it
        $pattern = '/(<div class="wn-wrapper"[^>]*>)(.*?)(<\/div>\s*<\/td>)/is';
        
        $args['message'] = preg_replace_callback($pattern, function($matches) {
            $wrapper_open = $matches[1];
            $content = $matches[2];
            $wrapper_close = $matches[3];
            
            // Format the inner content with proper paragraph and break tags
            return $wrapper_open . wpautop(trim($content)) . $wrapper_close;
        }, $args['message']);
    }
    
    return $args;
}

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.