这是我的功能,
class emailer {
function notifyHeart($post_ID) {
$interests = get_user_meta(get_current_user_id(), 'interests');
$to = the_author_meta( 'user_email', get_current_user_id() );
$post = get_post($post_ID);
foreach($interests as $interest) {
if(has_tag($interest, $post)) {
$email = $to;
mail($email, "An article about Heart", 'A new post has been published about heart.');
break;
}
}
}
}
add_action('publish_post', array('emailer', 'notifyHeart'));
发布帖子后出现错误,只有当我加入
时才会出现错误$to = the_author_meta( 'user_email', get_current_user_id() );
如果我改为包含此内容,
$to = "email@email.com";
没有警告发生。想什么?
答案 0 :(得分:0)
您只需要使用不同的WP功能:
// This actually echos the result right to the page, hence the headers error.
the_author_meta()
// Whereas this lets you capture the value into your $to variable:
get_the_author_meta()