Filter: postie_post_before

This filter is called just before Postie saves the post.

At the point the filter is called a placeholder post has been created, but it doesn’t have any content. All the attachments have been uploaded and associated with this post.

Parameters:

  • $post
  • $headers (available starting at version 1.7.28)

The $post parameter is an array describing the post extracted from the email.

Essentially any field described here can show up.

You may modify any of the array elements.

The $headers parameter is an array of email headers. 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

You must return the $post array from your function. You may return null to prevent the post from being saved.

Example without headers

add_filter('postie_post_before', 'my_postie_post_before');

function my_postie_post_before($post) {
    //Do something
    return $post;
}

Example with headers

add_filter('postie_post_before', 'my_postie_post_before', 10, 2);

function my_postie_post_before($post, $headers) {
    //Do something
    return $post;
}
Array index Notes
post_author the WordPress user that is the author of the post.
post_date the localized date of the post.
post_date_gmt the GMT/UMT date of the post.
post_content the actual content of the post.
post_title the post title (email subject line).
post_name the sanitized post title.
post_excerpt the post excerpt.
ID the post id.
post_status the post status.
post_category an array of category IDs
ping_status
comment_status
post_type

Note that if Postie detects a email reply it will add a comment to the original post and the data in the array will be as follows:

comment_author
comment_post_ID
comment_author_email
comment_date
comment_date_gmt
comment_content
comment_author_url
comment_author_IP
comment_approved
comment_agent
comment_type
comment_parent
user_id

See this for more details.

Comments are closed.