Action Since 3.0 uncanny-automator

automator_recipe_trigger_created

Fires when a new trigger is created for a recipe, providing its ID, code, and request data.

add_action( 'automator_recipe_trigger_created', $callback, 10, 3 );

Description

Fires immediately after a recipe trigger is successfully created via the REST API. Developers can use this hook to perform custom actions, such as logging trigger data, updating related database entries, or initializing custom logic tied to new trigger creations. It provides the trigger's post ID, item code, and the REST request object.


Usage

add_action( 'automator_recipe_trigger_created', 'your_function_name', 10, 3 );

Parameters

$post_id (int)
Trigger ID
$item_code (string)
Trigger item code
$request (WP_REST_Request)

Examples

<?php
/**
 * Logs details of newly created recipe triggers to the WordPress debug log.
 *
 * This function is hooked into the 'automator_recipe_trigger_created' action.
 * It receives the trigger ID, item code, and the REST request object.
 * It then logs these details to the WordPress debug log for monitoring and debugging purposes.
 *
 * @param int $post_id The ID of the newly created trigger post.
 * @param string $item_code The unique code identifying the trigger type.
 * @param WP_REST_Request $request The REST request object associated with the creation.
 */
function log_new_recipe_trigger_details( int $post_id, string $item_code, WP_REST_Request $request ) {
	if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
		error_log( sprintf(
			'Uncanny Automator: New recipe trigger created. Trigger ID: %d, Item Code: %s, Request Method: %s',
			$post_id,
			$item_code,
			$request->get_method()
		) );
	}
}
add_action( 'automator_recipe_trigger_created', 'log_new_recipe_trigger_details', 10, 3 );

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/automator-post-types/uo-recipe/class-recipe-post-rest-api.php:524

* @param int $post_id Trigger ID
			 * @param string $item_code Trigger item code
			 * @param WP_REST_Request $request
			 *
			 * @since 3.0
			 * @package Uncanny_Automator
			 */
			do_action( 'automator_recipe_trigger_created', $post_id, $item_code, $request );
		}

		if ( 'create_action' === $action ) {
			Automator()->set_recipe_part_meta( $post_id, $item_code, $integration_code, $post_type, $default_meta );

			/**
			 * @since 4.5


Internal Usage

Found in uncanny-automator-pro/src/integrations/magic-button/add-magic-button-integration.php:20:

add_action( 'automator_recipe_trigger_created', array( $this, 'magic_meta_add' ), 10, 3 );

Found in uncanny-automator-pro/src/integrations/run-now/class-run-now-integration.php:58:

add_action( 'automator_recipe_trigger_created', array( $this, 'publish_recipe' ), 10, 3 );

Found in uncanny-automator-pro/src/integrations/generator/add-generator-integration.php:20:

add_action( 'automator_recipe_trigger_created', array( $this, 'generator_meta_add' ), 10, 3 );

Found in uncanny-automator-pro/src/core/includes/automator-pro-cache-handler.php:28:

add_action( 'automator_recipe_trigger_created', array( $this, 'recipe_post_status_changed' ), 99999 );
Scroll to Top