Filter uncanny-automator

automator_is_background_action

Filters whether an automator action should run in the background, allowing modification of this behavior.

add_filter( 'automator_is_background_action', $callback, 10, 2 );

Description

Fires when determining if an action should run in the background. Developers can filter this to disable background processing for specific actions or under certain conditions, ensuring control over execution flow. The hook passes the background action status and the action object.


Usage

add_filter( 'automator_is_background_action', 'your_function_name', 10, 2 );

Parameters

$bg_action (mixed)
This parameter indicates whether the current action is configured for background processing.
$this (mixed)
This parameter contains the value that determines if an action should be processed in the background.

Return Value

The filtered value.


Examples

/**
 * Example of disabling background actions for a specific integration.
 *
 * This function checks if the current action is related to "event-tickets"
 * and if so, it disables background processing by returning false.
 *
 * @param mixed $bg_action The current background action status.
 * @param mixed $action    The action object.
 *
 * @return bool False if the action is related to event tickets, otherwise the original $bg_action.
 */
function disable_event_tickets_background_actions( $bg_action, $action ) {
	// Assuming $action object has a property or method to identify its type or integration.
	// This is a hypothetical check based on the provided internal usage example.
	if ( isset( $action->integration ) && 'event-tickets' === $action->integration ) {
		return false; // Disable background processing for event tickets
	}

	return $bg_action; // Otherwise, keep the original setting
}
add_filter( 'automator_is_background_action', 'disable_event_tickets_background_actions', 10, 2 );

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/classes/class-background-actions.php:290

public function is_bg_action() {

		$bg_action = Automator()->get->value_from_action_meta( $this->action_code, 'background_processing' );

		$bg_action = apply_filters( 'automator_is_background_action', $bg_action, $this->action );

		return $bg_action;
	}

Internal Usage

Found in uncanny-automator-pro/src/integrations/event-tickets/helpers/event-tickets-pro-helpers.php:137:

add_filter( 'automator_is_background_action', array( self::class, 'app_integration_disable_background_actions' ), 10, 2 );
Scroll to Top