automator_recipe_any_trigger_complete
Filters the recipe ID after any trigger within a recipe has successfully completed.
add_filter( 'automator_recipe_any_trigger_complete', $callback, 10, 1 );
Description
Fires after a recipe's trigger options have been processed. Developers can use this filter to modify the logic that determines if any trigger option is considered "complete" for a recipe, allowing for custom validation or override. The default behavior returns false if trigger logic is not set.
Usage
add_filter( 'automator_recipe_any_trigger_complete', 'your_function_name', 10, 1 );
Parameters
-
$recipe_id(mixed) - This parameter is a placeholder and is not used within the function.
Return Value
The filtered value.
Examples
// Example usage: Modify the behavior of the 'automator_recipe_any_trigger_complete' filter.
// This callback function will execute when a recipe's "any trigger" logic is evaluated.
// It checks if the recipe has a specific meta key set to 'any', and if so,
// it allows the trigger to complete. Otherwise, it prevents completion by returning false.
add_filter( 'automator_recipe_any_trigger_complete', 'my_custom_automator_any_trigger_logic', 10, 2 );
function my_custom_automator_any_trigger_logic( $should_complete, $recipe_id ) {
// $should_complete is the default value passed by the filter (typically false or true).
// $recipe_id is the ID of the current recipe being processed.
// In a real-world scenario, you might want to add custom conditions or
// logging here based on the recipe or other WordPress context.
// For this example, let's say we only want the "any trigger" to complete
// if a specific custom meta key is set on the recipe.
$custom_flag = get_post_meta( $recipe_id, 'my_custom_any_trigger_flag', true );
if ( 'yes' === $custom_flag ) {
// If our custom flag is set to 'yes', we explicitly allow the trigger to complete.
return true;
}
// If the custom flag is not set, we return the original $should_complete value,
// which the original function likely determined based on the 'automator_trigger_logic' meta.
// Or, if we wanted to override and *always* prevent completion if our flag isn't met,
// we could simply return false here.
return $should_complete;
}
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/process/class-automator-recipe-process-complete.php:246
src/core/lib/process/class-automator-recipe-process-complete.php:249
src/core/lib/process/class-automator-recipe-process-complete.php:252
public function is_any_trigger_option_set( $recipe_id ) {
$value = get_post_meta( $recipe_id, 'automator_trigger_logic', true );
if ( empty( $value ) ) {
return apply_filters( 'automator_recipe_any_trigger_complete', false, $recipe_id );
}
if ( 'any' !== $value ) {
return apply_filters( 'automator_recipe_any_trigger_complete', false, $recipe_id );
}
return apply_filters( 'automator_recipe_any_trigger_complete', true, $recipe_id );
}