Filter uncanny-automator-pro

automator_pro_post_updated_ignore_statuses

Filters post statuses that should be ignored when post updated actions trigger.

add_filter( 'automator_pro_post_updated_ignore_statuses', $callback, 10, 3 );

Description

Filters the post statuses that should trigger the "WP post updated" trigger. Developers can add or remove statuses from the default array ('trash', 'draft', 'future') to customize when this trigger fires, preventing unwanted automations when posts are moved between certain states.


Usage

add_filter( 'automator_pro_post_updated_ignore_statuses', 'your_function_name', 10, 3 );

Parameters

$post_ID (mixed)
This parameter is an array of post statuses that, when a post is updated to one of these statuses, will prevent the trigger from firing.
$post_after (mixed)
The ID of the post that was updated.
$post_before (mixed)
This parameter contains the post object *after* the update has been applied.

Return Value

The filtered value.


Examples

add_filter( 'automator_pro_post_updated_ignore_statuses', 'my_automator_ignore_post_statuses', 10, 4 );

/**
 * Example of how to add a custom post status to be ignored by the Post Updated trigger.
 *
 * This function will prevent the trigger from firing when a post is updated to a status of 'pending'.
 *
 * @param array $ignore_statuses An array of post statuses to ignore.
 * @param int   $post_ID         The ID of the post.
 * @param object $post_after      The post object after the update.
 * @param object $post_before     The post object before the update.
 * @return array Modified array of post statuses to ignore.
 */
function my_automator_ignore_post_statuses( $ignore_statuses, $post_ID, $post_after, $post_before ) {
	// Add 'pending' status to the list of statuses that should be ignored.
	$ignore_statuses[] = 'pending';

	return $ignore_statuses;
}

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

uncanny-automator-pro/src/integrations/wp/triggers/wp-postupdated.php:153

}

		// Prevent if publishing a post.
		if ( 'publish' === $post_after->post_status && 'publish' !== $post_before->post_status ) {
			return false;
		}

		$ignore_statuses = apply_filters(
			'automator_pro_post_updated_ignore_statuses',
			array(
				'trash',
				'draft',
				'future',
			),
			$post_ID,

Scroll to Top