Category: How To

Filter: postie_place_media

This filter is called before the palceholder (#img1#) is replaced with html markup.

Parameters:
  • $html – the html fragment that will replace the placeholder. This html is based on the template specified in the settings for the file type.
  • $media_id –  the ID of the media (image) being used to replace the placeholder.
add_filter('postie_place_media', 'my_postie_place_media', 10, 2);

function my_postie_place_media($html, $media_id) {
    return $html . '<p>This image is copyright by me</p>';
}

Filter: postie_email_notify_body

This filter is called before a success notification email is sent and can be used to modify the message body.

Parameters:
  • $body – a string that is the email body. The email is sent as text/plain so HTML is not supported.
  • $postemail – an array that represents the parsed email. See filter: postie_post_pre for more details.
  • $postid – the id of the post that has been created.
add_filter('postie_email_notify_body', 'my_postie_email_notify_body', 10, 3);

function my_postie_email_notify_body($body, $postemail, $postid) {
 return $body . "\nDieser Beitrag wurde abgelehnt";
}

Filter: postie_email_reject_body

This filter is called before a reject notification email is sent and can be used to modify the message body.

At the point the filter is called there is no post created.
Parameters:
  • $body – a string that is the email body. The email is sent as text/plain so HTML is not supported.
  • $postemail – an array that represents the parsed email. See filter: postie_post_pre for more details.
add_filter('postie_email_reject_body', 'my_postie_email_reject_body', 10, 2);

function my_postie_email_reject_body($body, $postemail) {
 return $body . "\nDieser Beitrag wurde abgelehnt";
}

Filter: postie_email_notify_subject

This filter is called before a success notification email is sent and can be used to modify the subject line.

Parameters:
  • $subject – a string that is the email subject.
  • $postemail – an array that represents the parsed email. See filter: postie_post_pre for more details.
  • $postid – the id of the post that has been created.
add_filter('postie_email_notify_subject', 'my_postie_email_notify_subject', 10, 3);

function my_postie_email_notify_subject($subject, $postemail, $postid) {
 return $subject . ' / Dieser Beitrag wurde geschrieben';
}

Filter: postie_email_reject_subject

This filter is called before a reject notification email is sent and can be used to modify the subject line.

At the point the filter is called there is no post created.
Parameters:
  • $subject – a string that is the email subject.
  • $postemail – an array that represents the parsed email. See filter: postie_post_pre for more details.
add_filter('postie_email_reject_subject', 'my_postie_email_reject_subject', 10, 2);

function my_postie_email_reject_subject($subject, $postemail) {
 return $subject . ' / Dieser Beitrag wurde abgelehnt';
}

Filter: postie_email_notify_recipients

This filter is called before a success notification email is sent and can be used to modify the recipient list.

Parameters:
  • $recipients – an array of email address that the email will be delivered to.
  • $postemail – an array that represents the parsed email. See filter: postie_post_pre for more details.
  • $postid – the id of the post that has been created.

Note that if you ever want to suppress the notification email return an empty array of recipients.

add_filter('postie_email_notify_recipients', 'my_postie_email_notify_recipients', 10, 3);

function my_postie_email_notify_recipients($recipients, $postemail, $postid) {
    $recipients[] = 'wayne@postieplugin.com';
    return $recipients;
 }

Filter: postie_email_reject_recipients

This filter is called before a reject notification email is sent and can be used to modify the recipient list.

At the point the filter is called there is no post created.
Parameters:
  • $recipients – an array of email address that the email will be delivered to.
  • $postemail – an array that represents the parsed email. See filter: postie_post_pre for more details.

Note that if you ever want to suppress this email return an empty array of recipients.

add_filter('postie_email_reject_recipients', 'my_postie_email_reject_recipients', 10, 2);

function my_postie_email_reject_recipients($recipients, $postemail) {
 $recipients[] = 'wayne@postieplugin.com';
 return $recipients;
 }

Filter: postie_filter_email3

This filter is called when Postie extracts the “from” email address. Typically you would use this filter if you wanted to use the email headers to decide which email address should be used to identify the WordPress user.
At the point the filter is called there is no post created.
Parameters:
  • $fromEmail – the email address that the email is from. Note that filters postie_filter_email and postie_filter_email2 could have modified this already.
  • $headers – an array of all the email headers received. Note that this will vary depending on where the email came from. You can get a sense of what is possible here: https://tools.ietf.org/html/rfc2076
add_filter('postie_filter_email3', 'my_filterEmail3', 10, 2);

function my_filterEmail3($fromEmail, $headers) {
    if (array_key_exists('Sender', $headers)) {
        $fromEmail = $headers['Sender'];
    }
    return $fromEmail;
}

See also: