Action
uncanny-automator-pro
automator_pro_action_condition_failed
Fires when an Automator Pro action's condition fails, allowing custom logic to be executed.
add_action( 'automator_pro_action_condition_failed', $callback, 10, 3 );
Description
Fires when an action condition fails within Uncanny Automator Pro. Developers can use this hook to log specific failure details, prevent further processing, or trigger custom logic when an action's conditions are not met, ensuring precise control over automation workflows.
Usage
add_action( 'automator_pro_action_condition_failed', 'your_function_name', 10, 3 );
Parameters
-
$this(mixed) - This parameter represents the current `ActionCondition` object.
-
$this(mixed) - This parameter holds the instance of the `Action_Condition` class that is triggering the hook.
-
$log_message(mixed) - This parameter represents the current instance of the `Action_Condition` object, providing access to its properties and methods.
Examples
// Add a custom log entry to the WordPress debug log when an Uncanny Automator Pro action condition fails.
add_action(
'automator_pro_action_condition_failed',
function ( $action_data, $action_code, $log_message ) {
// Check if the 'automator_debug_log' option is enabled in WordPress.
if ( get_option( 'automator_debug_log', 'no' ) === 'yes' ) {
// Format the log message with relevant details.
$debug_log_message = sprintf(
'[Uncanny Automator Pro] Action Condition Failed: Action Code: %s | Log: %s',
esc_html( $action_code ),
esc_html( $log_message )
);
// Write the formatted message to the WordPress debug log.
error_log( $debug_log_message );
}
},
10, // Priority of the hook.
3 // Number of arguments accepted by the callback function.
);
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/core/classes/action-condition.php:330
public function condition_failed( $log_message = '' ) {
$log_message = apply_filters( 'automator_pro_actions_conditions_log_message', $log_message, $this );
if ( empty( $log_message ) ) {
$log_message = $this->name . __( ' failed', 'uncanny-automator-pro' );
}
$this->action['process_further'] = false;
$this->action['action_data']['failed_actions_conditions'] = true;
$this->action['action_data']['actions_conditions_log'][] = sanitize_text_field( $log_message );
do_action( 'automator_pro_action_condition_failed', $this->action, $this->code, $log_message );
}