Filter uncanny-automator

automator_wpai_post_type_imported_run_on_update

Filters the post ID after a post is imported or updated via WP All Import.

add_filter( 'automator_wpai_post_type_imported_run_on_update', $callback, 10, 1 );

Description

Filters whether the WP All Import Post Type Imported trigger should execute when an existing post is updated. Return `true` to allow the trigger to run on updates, otherwise return `false` (the default) to prevent it. This hook fires after checking if a post is being updated but before the trigger's main logic.


Usage

add_filter( 'automator_wpai_post_type_imported_run_on_update', 'your_function_name', 10, 1 );

Parameters

$post_id (mixed)
This parameter determines whether the trigger should execute when an existing post is updated by WP All Import.

Return Value

The filtered value.


Examples

/**
 * Example: Only run the automator trigger on post type import updates if the post has a specific meta key.
 */
add_filter(
	'automator_wpai_post_type_imported_run_on_update',
	function ( $run_on_update, $post_id ) {
		// Check if the post has a specific meta key set.
		// If it does, we allow the trigger to run on update.
		$specific_meta_key_value = get_post_meta( $post_id, '_my_custom_trigger_key', true );

		if ( ! empty( $specific_meta_key_value ) ) {
			return true; // Allow the trigger to run on update
		}

		return $run_on_update; // Otherwise, respect the original value (false by default)
	},
	10,
	2
);

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/integrations/wp-all-import/triggers/wpai-post-type-imported.php:89

protected function validate_trigger( ...$args ) {
		list( $post_id, $xml_node, $is_updated ) = array_shift( $args );

		if ( empty( $post_id ) ) {
			return false;
		}

		// Check if trigger should run on update.
		if ( ! empty( $is_updated ) ) {
			$run_on_update = apply_filters( 'automator_wpai_post_type_imported_run_on_update', false, $post_id );
			if ( ! $run_on_update ) {
				return false;
			}
		}

		return true;
	}

Scroll to Top