automator_wp_post_updates_include_non_public_posts
Filters whether non-public posts should be included in post update automations.
add_filter( 'automator_wp_post_updates_include_non_public_posts', $callback, 10, 1 );
Description
Filters whether to include non-public posts in WordPress trigger updates. Developers can return `true` to include drafts, private posts, and other non-published statuses, or `false` to exclude them. This allows fine-grained control over which post status changes trigger automations.
Usage
add_filter( 'automator_wp_post_updates_include_non_public_posts', 'your_function_name', 10, 1 );
Parameters
-
$post(mixed) - This parameter determines whether to include non-public posts in the post update triggers.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the 'automator_wp_post_updates_include_non_public_posts' filter.
* This example will include posts with the 'draft' status, in addition to other non-public statuses
* that might already be included by default.
*/
add_filter(
'automator_wp_post_updates_include_non_public_posts',
function ( $include_non_public, $post_id ) {
// Get the post object to check its status
$post = get_post( $post_id );
// If it's a draft post, explicitly include it
if ( $post && 'draft' === $post->post_status ) {
return true;
}
// Otherwise, return the default value provided by the filter
return $include_non_public;
},
10, // Priority
2 // Accepted arguments (boolean $include_non_public, int $post_id)
);
?>
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/core/lib/utilities/class-automator-utilities.php:805
src/integrations/wp/triggers/wp-user-updates-post.php:109
src/integrations/wp/triggers/wp-anon-updates-post.php:114
src/integrations/wp/triggers/anon-wp-updates-post-in-taxonomy.php:200
uncanny-automator-pro/src/integrations/wp/triggers/wp-postinstatusupdated.php:137
uncanny-automator-pro/src/integrations/wp/triggers/wp-postintaxonomyupdated.php:161
public function is_wp_post_being_published( $post, $post_before ) {
// If this is an autosave, bail
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return false;
}
// If this post is not published yet, bail
if ( 'publish' !== $post->post_status ) {
return false;
}
// If this post was published before, bail
if ( ! empty( $post_before->post_status ) && 'publish' === $post_before->post_status ) {
return false;
}
// Include attachment, revision etc
$include_non_public_posts = apply_filters(
'automator_wp_post_updates_include_non_public_posts',
false,
$post->ID
);
if ( false === $include_non_public_posts ) {
$__object = get_post_type_object( $post->post_type );
if ( isset( $__object->public ) && false === $__object->public ) {
return false;
}
}
// Otherwise, return true
return true;
}