• Resolved Cristiano

    (@iclapton)


    Hi Postie friends,

    Thanks for your great plugin. I’m working on a CRM project using Postie and it works great! Just a question about the filter…

    Using postie_post_before (or other), is there an easy way to know if the email is a response or not? I mean, since Postie needs to do it before save the post, it uses any variable to store it that we can use?

    I’m trying to do it this way:

    $email_title = $post['post_title'];
    $find = "Re:";
    $email_response = stripos($email_title, $find);
    
    if ( $email_resposta !== false ) {
    	$response = true;
    } else {
    	$response = false;
    }

    It looks good, but always return false, even if it’s a response.

    Any help??
    Thanks!

    https://www.ads-software.com/plugins/postie/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter Cristiano

    (@iclapton)

    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??

    Thread Starter Cristiano

    (@iclapton)

    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?

    Thread Starter Cristiano

    (@iclapton)

    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.

    Thread Starter Cristiano

    (@iclapton)

    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.

    Thread Starter Cristiano

    (@iclapton)

    Is there a way to know if the incoming email is a reply or not?

    Plugin Author Wayne Allen

    (@wayneallen-1)

    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);

    Thread Starter Cristiano

    (@iclapton)

    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.

    Thread Starter Cristiano

    (@iclapton)

    Running Postie with debug mode I couldn’t find the key comment_post_ID on the log also…

    Plugin Author Wayne Allen

    (@wayneallen-1)

    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

    Thread Starter Cristiano

    (@iclapton)

    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

    Plugin Author Wayne Allen

    (@wayneallen-1)

    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;
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Using filter postie_post_before to identify a response’ is closed to new replies.