Sharing: publicize_should_publicize_published_post filter ignored via API/XML-RPC
Steps to reproduce the issue
- Create filter to exclude category
- Publish post in that category via WordPress app
What I expected
Expected post to be omitted from publicize
What happened instead
Filter returned true and post was published
Could you give us more details about this?
- What is the URL of the post that got publicized?
- What is the code snippet you use on your site to exclude categories?
- What WordPress app did you use to post? A mobile app? A desktop app? Could you specify the version as well?
Thank you!
Sure! Here are some more details:
Here is the filter I’m using in a site specific plugin:
// Do not trigger Jetpack Publicize if the post uses the 'status' post format.
add_filter( 'publicize_should_publicize_published_post', 'minimum_control_publicize', 10, 2 );
function minimum_control_publicize( $should_publicize, $post ) {
// Return early if we don't have a post yet (it hasn't been saved as a draft)
if ( !$post ) {
return $should_publicize;
}
// Return false is the format is 'status'
if ( has_post_format( 'status' ) ) {
return false;
}
return $should_publicize;
}
This post was published using the Workflow for iOS app and set as a status post format and still triggered publicize:
http://www.chrisreedtech.com/960-2/
I’ve tried the following apps:
- WordPress for iOS (v. 9.0.1)
- Workflow for iOS
- Micro.Blog iOS and Desktop apps
Let me know if there’s any other details I can provide.
I'm not sure that snippet is going to work. Since you are not in the loop, when using has_post_format you would need to specify a post ID, like so:
if ( has_post_format( 'status', $post->ID ) ) {
(reference)
Let me know how it goes.
Thanks worked! Thanks--it was confusing because without the post ID it was still working via the post editor. Sorry for the false alarm and I really appreciate the help.