【问题标题】:How to Send Email blog post to specific members in wordpress?如何将电子邮件博客文章发送给 wordpress 中的特定成员?
【发布时间】:2022-01-30 16:53:41
【问题描述】:
当我在 wordpress 博客中发布文章并将其分配到特定类别时,是否有一种简单的方法可以使用 ULTIMATE MEMBERSHIP PRO 将该帖子发送给特定的成员组?例如,当我发布一篇文章并将其分配到 A、B 和 C 类别时...我想自动化一个流程来获取该博客文章的内容并通过电子邮件将其发送到 MAILING TOOLS 中的 A、B 和 C 组.
我当然愿意接受可以实现我目标的插件。实际上,我更喜欢支持良好的插件。
【问题讨论】:
标签:
php
html
wordpress
plugins
mailchimp
【解决方案1】:
我不确定具体的插件,但您可以使用 save_post 钩子解决这个问题。
add_action( 'save_post', 'send_email_to_users', 10,3);
function send_email_to_users( $post_id, $post, $update ) {
// Only want to set if this is a new post!
if ( $update ){
return;
}
// Only set for post_type = post!
if ( 'post' !== $post->post_type ) {
return;
}
// if (<already_sent> == true) { return; }
// Check if the post has the categories A, B, C.
// Mail users about the blog.
// create a custom field to record, if you have sent them email.
}