WPIntell

Source evidence

html emails

AsynCRONous bbPress Subscriptions 路 support 路 2019-02-11T09:24:00+00:00

mixedsentiment
mediumseverity
0.84relevance
8replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

3 / 31 rows with source links

9.7% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

28 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
wpturk resolved
Hi Markus, I would like to send html emails with this plugin. Can you give me a hint? Is there an easy way? Hi @wpturk , try something like this (e.g. added to your theme鈥檚 functions.php): add_filter( 'bbp_subscription_email_headers', function( $headers ) { array_push( $headers, 'MIME-Version: 1.0', 'Content-Type: text/html; charset=UTF-8' ); return $headers; } ); add_filter( 'bbp_forum_subscription_email_message', function( $message, $forum_id, $topic_id ) { $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); $topic_author_display_name = bbp_get_topic_author_display_name( $topic_id ); $topic_url = get_permalink( $topic_id ); $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); return sprintf( '<p>%s posted new topic <a href="%s">%s</a></p><p>%s</p>', $topic_author_display_name, $topic_url, $topic_title, $topic_content ); } ); add_filter( 'bbp_topic_subscription_email_message', function( $message, $forum_id, $topic_id, $reply_id ) { $reply_author_display_name = bbp_get_reply_author_display_name( $reply_id ); $reply_url = bbp_get_reply_url( $reply_id ); $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); return sprintf( '<p>%s replied:</p><p>%s</p><p><a href="%s">Read Online</a></p>', $reply_author_display_name, $reply_content, $reply_url ); } ); Thank you Markus, this is great. I will test. Do you know any easy way to use an email template, so that your functions only push topic_title, topic_author_display_name, topic_url, topic_content etc. and all html/css stuff comes from the template. Sure. In the above example code, the message filters return an html string. That string could also be loaded from a template by using php output buffers like so: ob_start(); include( get_stylesheet_directory() . '/email_templates/new_topic_message.html' ); $ob = ob_get_clean(); Then you simply replace any tokens in the template with author name, content etc and return the result. Hi Markus, I get somehow blank page after posting a reply. I used your above code in functions.php add_filter( 'bbp_subscription_email_headers', function( $headers ) { array_push( $headers, 'MIME-Version: 1.0', 'Content-Type: text/html; charset=UTF-8' ); return $headers; } ); add_filter( 'bbp_forum_subscription_email_message', function( $message, $forum_id, $topic_id ) { $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); $topic_author_display_name = bbp_get_topic_author_display_name( $topic_id ); $topic_url = get_permalink( $topic_id ); $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); return sprintf( '<p>%s posted new topic <a href="%s">%s</a></p><p>%s</p>', $topic_author_display_name, $topic_url, $topic_title, $topic_content ); } ); add_filter( 'bbp_topic_subscription_email_message', function( $message, $forum_id, $topic_id, $reply_id ) { $reply_author_display_name = bbp_get_reply_author_display_name( $reply_id ); $reply_url = bbp_get_reply_url( $reply_id ); $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); return sprintf( '<p>%s replied:</p><p>%s</p><p><a href="%s">Read Online</a></p>', $reply_author_display_name, $reply_content, $reply_url ); } ); Sorry about that. The code was untested. The number of filter arguments was missing and also I discovered that the MIME type was added a second time by WordPress, so I removed that part. Here is a tested version that works for me: add_filter( 'bbp_subscription_email_headers', function( $headers ) { $headers []= 'Content-Type: text/html; charset=UTF-8'; return $headers; } ); add_filter( 'bbp_forum_subscription_email_message', function( $message, $forum_id, $topic_id ) { $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); $topic_author_display_name = bbp_get_topic_author_display_name( $topic_id ); $topic_url = get_permalink( $topic_id ); $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); return sprintf( '<p>%s posted new topic <a href="%s">%s</a></p><p>%s</p>', $topic_author_display_name, $topic_url, $topic_title, $topic_content ); }, 10, 3 ); add_filter( 'bbp_topic_subscription_email_message', function( $message, $forum_id, $topic_id, $reply_id ) { $reply_author_display_name = bbp_get_reply_author_display_name( $reply_id ); $reply_url = bbp_get_reply_url( $reply_id ); $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); return sprintf( '<p>%s replied:</p><p>%s</p><p><a href="%s">Read Online</a></p>', $reply_author_display_name, $reply_content, $reply_url ); }, 10, 4 ); *MIME version, not type. Works like a charm! Thanks for your 5 star support! Glad I could help. Thanks for your friendly review. 馃檪

Comments

8 shown
Markus Echterhoff 2019-02-11T09:49:00+00:00

Hi @wpturk , try something like this (e.g. added to your theme鈥檚 functions.php): add_filter( 'bbp_subscription_email_headers', function( $headers ) { array_push( $headers, 'MIME-Version: 1.0', 'Content-Type: text/html; charset=UTF-8' ); return $headers; } ); add_filter( 'bbp_forum_subscription_email_message', function( $message, $forum_id, $topic_id ) { $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); $topic_author_display_name = bbp_get_topic_author_display_name( $topic_id ); $topic_url = get_permalink( $topic_id ); $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); return sprintf( '<p>%s posted new topic <a href="%s">%s</a></p><p>%s</p>', $topic_author_display_name, $topic_url, $topic_title, $topic_content ); } ); add_filter( 'bbp_topic_subscription_email_message', function( $message, $forum_id, $topic_id, $reply_id ) { $reply_author_display_name = bbp_get_reply_author_display_name( $reply_id ); $reply_url = bbp_get_reply_url( $reply_id ); $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); return sprintf( '<p>%s replied:</p><p>%s</p><p><a href="%s">Read Online</a></p>', $reply_author_display_name, $reply_content, $reply_url ); } );

wpturk 2019-02-11T17:47:00+00:00

Thank you Markus, this is great. I will test. Do you know any easy way to use an email template, so that your functions only push topic_title, topic_author_display_name, topic_url, topic_content etc. and all html/css stuff comes from the template.

Markus Echterhoff 2019-02-11T18:05:00+00:00

Sure. In the above example code, the message filters return an html string. That string could also be loaded from a template by using php output buffers like so: ob_start(); include( get_stylesheet_directory() . '/email_templates/new_topic_message.html' ); $ob = ob_get_clean(); Then you simply replace any tokens in the template with author name, content etc and return the result.

wpturk 2019-02-12T00:43:00+00:00

Hi Markus, I get somehow blank page after posting a reply. I used your above code in functions.php add_filter( 'bbp_subscription_email_headers', function( $headers ) { array_push( $headers, 'MIME-Version: 1.0', 'Content-Type: text/html; charset=UTF-8' ); return $headers; } ); add_filter( 'bbp_forum_subscription_email_message', function( $message, $forum_id, $topic_id ) { $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); $topic_author_display_name = bbp_get_topic_author_display_name( $topic_id ); $topic_url = get_permalink( $topic_id ); $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); return sprintf( '<p>%s posted new topic <a href="%s">%s</a></p><p>%s</p>', $topic_author_display_name, $topic_url, $topic_title, $topic_content ); } ); add_filter( 'bbp_topic_subscription_email_message', function( $message, $forum_id, $topic_id, $reply_id ) { $reply_author_display_name = bbp_get_reply_author_display_name( $reply_id ); $reply_url = bbp_get_reply_url( $reply_id ); $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); return sprintf( '<p>%s replied:</p><p>%s</p><p><a href="%s">Read Online</a></p>', $reply_author_display_name, $reply_content, $reply_url ); } );

Markus Echterhoff 2019-02-12T10:19:00+00:00

Sorry about that. The code was untested. The number of filter arguments was missing and also I discovered that the MIME type was added a second time by WordPress, so I removed that part. Here is a tested version that works for me: add_filter( 'bbp_subscription_email_headers', function( $headers ) { $headers []= 'Content-Type: text/html; charset=UTF-8'; return $headers; } ); add_filter( 'bbp_forum_subscription_email_message', function( $message, $forum_id, $topic_id ) { $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); $topic_author_display_name = bbp_get_topic_author_display_name( $topic_id ); $topic_url = get_permalink( $topic_id ); $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); return sprintf( '<p>%s posted new topic <a href="%s">%s</a></p><p>%s</p>', $topic_author_display_name, $topic_url, $topic_title, $topic_content ); }, 10, 3 ); add_filter( 'bbp_topic_subscription_email_message', function( $message, $forum_id, $topic_id, $reply_id ) { $reply_author_display_name = bbp_get_reply_author_display_name( $reply_id ); $reply_url = bbp_get_reply_url( $reply_id ); $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); return sprintf( '<p>%s replied:</p><p>%s</p><p><a href="%s">Read Online</a></p>', $reply_author_display_name, $reply_content, $reply_url ); }, 10, 4 );

Markus Echterhoff 2019-02-12T11:23:00+00:00

*MIME version, not type.

wpturk 2019-02-12T11:50:00+00:00

Works like a charm! Thanks for your 5 star support!

Markus Echterhoff 2019-02-12T14:19:00+00:00

Glad I could help. Thanks for your friendly review. 馃檪