Shortcodes in HTML Mail
-
Hello,
is it possible to add shortcodes to the mail text? The reason is, that I would like to use a custom function to generate the HTML E-Mails. I thought I could bind this function to a shortcode and insert this shortcode in the e-mail fields, but they are not converted.
Anyone got any tips?Thanks!
-
Hi @traxx,
There is “hidden” filter that is apply to the email content, the name is
stcr_notify_user_message
so In order to use it you have to add the filter with that name. Something like this.function stcr_notify_user_message_callback( $message, $_post_ID, $clean_email, $_comment_ID ) { $message = "<h1>Some cool text filtered</h1>" . $message; return $message; } add_filter("stcr_notify_user_message", "stcr_notify_user_message_callback", 10, 4);
Then the email message will get what you need, you are free to replace all the content or add existing one.
Regards.!!
Perfect, that’s exactly what I was looking for!!
But I have two more questions:
- I cannot use your shortcodes (for example [post_permalink], [comment_author], [comment_reply_permalink]) inside this function. Or also the PHP variables, for example $post_permalink, $comment_permalink or $comment->comment_author. How is it possible to use this dynamic information inside the filter?
- I have to use the double opt in option. It seems there is no filter for this email message to confirm the subscription. Is there an easy way to add this myself?
I appreciate your support. Thank you very much!
HI @traax,
I cannot use your shortcodes (for example [post_permalink], [comment_author], [comment_reply_permalink]) inside this function. Or also the PHP variables, for example $post_permalink, $comment_permalink or $comment->comment_author. How is it possible to use this dynamic information inside the filter?
Actually these are only tags that you can use withing the custom messages instead of shortcodes. So far I never had the request to use them as a shortcode. Can I question what is your goal?
I have to use the double opt in option. It seems there is no filter for this email message to confirm the subscription. Is there an easy way to add this myself?
If you go to the StCR
Settings>Management Page
, you will see the Subscription processed (DCI) Setting where you can customize that message, these are the valid tags:[post_title], [post_permalink]
.Regards.!!
Hello,
my goal is, to generate the HTML Mails completely inside a php function, because I have a class for generating a HTML E-Mail.
The filter “stcr_notify_user_message” is good, but I cannot access the link or the author for example. But I need this information for generating a complete mail.And I would like to know if there is a filter that is apply to the email content of the double opt in email, which is send after subscribing to a comment.
Thank you
- The topic ‘Shortcodes in HTML Mail’ is closed to new replies.