Filter
uncanny-automator-pro
automator_pro_action_condition_is_dependency_active
Filter to override the dependency active status for a specific condition. Filters the active status of a specific Automator Pro action condition before it's applied.
add_filter( 'automator_pro_action_condition_is_dependency_active', $callback, 10, 4 );
Description
This filter hook allows developers to programmatically override whether a specific condition's dependency is considered active. It fires when a condition's dependency status is being checked. Use this to manually control dependency activation based on custom logic, potentially bypassing default checks.
Usage
add_filter( 'automator_pro_action_condition_is_dependency_active', 'your_function_name', 10, 4 );
Parameters
-
$is_active(bool) - The dependency active status.
-
$integration(string) - The integration code.
-
$code(string) - The condition code.
-
$condition(object) - The condition instance.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the 'automator_pro_action_condition_is_dependency_active' filter.
*
* This example demonstrates how to conditionally disable a specific integration's
* dependency for a particular condition. In this case, we're disabling the
* "gravityforms" integration's dependency for the "form_submitted" condition
* if the user has a specific meta key set in their user profile.
*
* @param bool $is_active The dependency active status.
* @param string $integration The integration code.
* @param string $code The condition code.
* @param object $condition The condition instance.
* @return bool The modified dependency active status.
*/
add_filter( 'automator_pro_action_condition_is_dependency_active', function ( $is_active, $integration, $code, $condition ) {
// Check if the current integration is 'gravityforms' and the condition code is 'form_submitted'.
if ( $integration === 'gravityforms' && $code === 'form_submitted' ) {
// Get the current user ID.
$user_id = get_current_user_id();
// If we have a logged-in user, check for a specific meta key.
if ( $user_id && get_user_meta( $user_id, 'disable_gravityforms_dependency', true ) === 'yes' ) {
// If the meta key is set to 'yes', deactivate the dependency.
$is_active = false;
}
}
// Return the potentially modified active status.
return $is_active;
}, 10, 4 );
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:132
protected function is_dependency_active() {
$is_active = true;
/**
* Filter to override the dependency active status for a specific condition.
*
* @param bool $is_active The dependency active status.
* @param string $integration The integration code.
* @param string $code The condition code.
* @param object $condition The condition instance.
*/
return apply_filters( 'automator_pro_action_condition_is_dependency_active', $is_active, $this->integration, $this->code, $this );
}