It looks like Postie takes off the “Re:” string of the subject before the postie_post_before filter…
I just realize that if I print the $post[‘post_title’], it doesn’t have the “Re:” string, but Postie recognize it as a response, as Postie saves it as a comment…
What should I do so??
I tried to get the $post[‘comment_author’], hoping that a “no response” email have it empty, but that is not the case.
Any help please?
New try:
$email_resp = $post['comment_content'] . $post['comment_post_ID'] . $post['comment_author_email'] . $post['comment_date'] . $post['comment_date_gmt'] . $post['comment_author_url'] . $post['comment_author_IP'] . $post['comment_approved'] . $post['comment_agent'] . $post['comment_type'] . $post['comment_parent'] . $post['user_id'];
if ( $email_resp ) {
echo "this is a reply";
} else {
echo "no reply";
}
It doesn’t work. $email_resp is always empty, doesn’t matter if it’s a reply or not.
Tried the same as the last one, but with the postie_post_after filter… the $email_resp variable is still empty. I really don’t know what to do.
Is there a way to know if the incoming email is a reply or not?
Look for the array element “comment_post_ID” to see if the post is a response.
i.e.
$response = array_key_exists('comment_post_ID', $post);
Hi Wayne,
Sorry, I just saw your answer… in fact, I tried this and couldn’t get it working…
Tried this:
if (array_key_exists('comment_post_ID', $post)) {
$comment = "yes";
} else {
$comment = "no";
}
and this:
if (isset($post['comment_post_ID'])) {
$comment = "yes";
} else {
$comment = "no";
}
And both returns “no”… although Postie gets the email and publish it as a comment.
Running Postie with debug mode I couldn’t find the key comment_post_ID on the log also…
Sorry, I didn’t look close enough. I’ve added 2 new filter hooks postie_comment_before and postie_comment_after in version 1.7.6
Hey Wayne, how are you doing?
Now I have another problems, probably related to this…
Let me underestand… I’m using the ‘postie_post_before’ filter. Using this to get the email’s subject: “$subject = $post[‘post_title’];”. After version 1.7.6, if this email is a reply, I still get the post_title (email’s subject) this way?
More than that, if it’s a reply, the ‘postie_post_before’ filter will work? Or I need to use instead ‘postie_comment_before’? And, if it’s the case, How can I get the post_title/email subject?
Thanks
If you have Postie set to treat replies as comments you will need to hook postie_comment_before. You can get the post title like this:
$post = get_post($comment['comment_post_ID']);
$title = $post->post_title;