2012-12-20 5 views
0

가 여기 내 함수의에서 전송 헤더를.. 경고 : 헤더 정보를 수정할 수 없습니다 - 이미

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 protected]"; 

없음 경고를 포함하지 않는 경우 나오다. 누구를 생각해?

답변

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() 
+0

실제로는 the_content 같은 여러 기능을 통해 사용되는로 워드 프레스로 기억하는 엄지 손가락의 좋은 규칙의()와 get_the_content(). – hansvedo

+0

Gotcha, 고개를 숙여 주셔서 감사합니다. 미래의 마음에 분명히 명심하십시오. – Richard

관련 문제