Action
Since 3.0
uncanny-automator
automator_recipe_closure_created
Fires when a new closure is successfully created for a recipe, providing its ID, code, and request data.
add_action( 'automator_recipe_closure_created', $callback, 10, 3 );
Description
Fires after a new closure is created for a recipe, typically within the REST API context. Developers can use this hook to perform actions related to the newly created closure, such as updating related data or triggering subsequent processes. The hook provides the closure's post ID, item code, and the original REST request.
Usage
add_action( 'automator_recipe_closure_created', 'your_function_name', 10, 3 );
Parameters
-
$post_id(int) - Closure ID
-
$item_code(string) - Closure item code
-
$request(WP_REST_Request)
Examples
/**
* Logs the creation of a new recipe closure for debugging purposes.
*
* @param int $post_id The ID of the created recipe closure (post ID).
* @param string $item_code The unique code for the closure item.
* @param WP_REST_Request $request The WordPress REST API request object.
*/
function my_automator_log_recipe_closure_creation( $post_id, $item_code, WP_REST_Request $request ) {
// Ensure we are in a context where logging is appropriate.
// For instance, you might want to avoid logging during AJAX requests that are not part of a specific process.
if ( wp_doing_ajax() && ! isset( $_POST['is_automator_ajax_call'] ) ) {
return;
}
// Log the event with relevant details.
// This could be written to a custom log file, a database table, or the WordPress debug log.
error_log( sprintf(
'Uncanny Automator: New recipe closure created. Post ID: %1$d, Item Code: %2$s, Request Method: %3$s, User ID: %4$d',
$post_id,
$item_code,
$request->get_method(),
get_current_user_id()
) );
// You could also potentially trigger other actions here based on the closure creation.
// For example, sending a notification or updating some statistics.
// For this example, we'll just log.
}
add_action( 'automator_recipe_closure_created', 'my_automator_log_recipe_closure_creation', 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:565
* @param int $post_id Closure ID
* @param string $item_code Closure item code
* @param WP_REST_Request $request
*
* @since 3.0
* @package Uncanny_Automator
*/
do_action( 'automator_recipe_closure_created', $post_id, $item_code, $request );
}
if ( ! empty( $default_meta ) && is_array( $default_meta ) ) {
foreach ( $default_meta as $meta_key => $meta_value ) {
if (
true === apply_filters( 'automator_sanitize_input_fields', true, $meta_key, $meta_value, $recipe->ID ) &&
true === apply_filters( 'automator_sanitize_input_fields_' . $recipe->ID, true, $meta_key, $meta_value )
Internal Usage
Found in uncanny-automator-pro/src/core/includes/automator-pro-cache-handler.php:29:
add_action( 'automator_recipe_closure_created', array( $this, 'recipe_post_status_changed' ), 99999 );