【发布时间】:2020-05-15 11:09:11
【问题描述】:
我想在文章发表后给作者发邮件。
我的代码
add_action( 'publish_post', 'send_notification' );
function send_notification( $post_id ) {
$post = get_post($post_id);
$content = $post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$post_url = get_permalink( $post_id );
$post_title = get_the_title( $post_id );
$author = get_userdata($post->post_author);
$subject = '$post_title';
$message .= "<a href='". $post_url. "'>'".$post_title."'</a>\n\n";
$message .= $content;
wp_mail($author->user_email, $subject, $message );
}
邮件正常发送给作者,但他阅读了帖子内容的源代码。
我应该怎么做才能让作者正常通过电子邮件而不是帖子中的代码获取帖子
感谢您的帮助!
【问题讨论】:
标签: php wordpress email post author