Okay I hacked myself a solution but this will need to be reapplied every time Email Users is updated. Basically I changed email-users.php and changed this:
if ('html' == $type) {
if (mailusers_get_add_mime_version_header() == 'true')
$headers[] = 'MIME-Version: 1.0';
$headers[] = sprintf('Content-Type: %s; charset="%s"', get_bloginfo('html_type'), get_bloginfo('charset')) ;
$mailtext = "<html><head><title>" . $subject . "</title></head><body>" . $message . $footer . "</body></html>";
} else {
if (mailusers_get_add_mime_version_header() == 'true')
$headers[] = 'MIME-Version: 1.0';
$headers[] = sprintf('Content-Type: text/plain; charset="%s"', get_bloginfo('charset')) ;
$message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
$message = preg_replace('|&|', '&', $message);
$mailtext = wordwrap(strip_tags($message . "\n" . $footer), 80, "\n");
}
to this …
if ('html' == $type) {
if (mailusers_get_add_mime_version_header() == 'true')
$headers[] = 'MIME-Version: 1.0';
$mailtext = $message;
} else {
if (mailusers_get_add_mime_version_header() == 'true')
$headers[] = 'MIME-Version: 1.0';
$headers[] = sprintf('Content-Type: text/plain; charset="%s"', get_bloginfo('charset')) ;
$message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
$message = preg_replace('|&|', '&', $message);
$mailtext = wordwrap(strip_tags($message . "\n" . $footer), 80, "\n");
}
And now it works.
An option to omit the HTML-Body-Wrapper would be better!
One quick correction: you have to make sure that wp better mail doesn’t get any newlines as it uses nl2br messing up HTML. So I stripped them (along with comments etc.):
if ('html' == $type) {
if (mailusers_get_add_mime_version_header() == 'true')
$headers[] = 'MIME-Version: 1.0';
$mailtext = preg_replace(array('/ {2,}/','/<!--.*?-->|\t|(?:\r?\n[ \t]*)+/s'),array(' ',''),$message);
} else {
if (mailusers_get_add_mime_version_header() == 'true')
$headers[] = 'MIME-Version: 1.0';
$headers[] = sprintf('Content-Type: text/plain; charset="%s"', get_bloginfo('charset')) ;
$message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
$message = preg_replace('|&|', '&', $message);
$mailtext = wordwrap(strip_tags($message . "\n" . $footer), 80, "\n");
}
I will look at adding a hook or filter to allow you to do something like you are proposing.
It may be the sort of thing where the plugin has a default filter which you would need to remove in order to use your own HTML wrapper. That is my initial thinking on it as I sit here are Newark airport this morning waiting to go home. It will likely be a few days, maybe a week before I can look at this as I have a lot on my plate at work.
Thumbs up. Looking forward to a maintainable solution! Thanks.
I have added the mailusers_html_wrapper filter and released 4.7.2. You can read more details and see an example of using the new filter on my web site.
Thank you so much Max Ziebell.
Although I got the newest version of Email Users I used the dirty trick of Max.
I already got my template with wp better emails and all I wanted was Email users to insert the plain text into the template.
Max’s solution breaks when Email Users is updated which I expect to do shortly as I have fixed another bug in the activation code when a site has a large number of users.
I have written up a post which explains the proper way to have WPBE and Email Users work together. The solution was posted in the comments on my blog last week.
There is an example (examples/wpbe.php) on how to setup the filters for WPBE and Email Users to work together in the 4.7.3 update which I pushed out today.