Filter uncanny-automator

automator_actions

Filters the available Automator actions before they are displayed or used in the plugin.

add_filter( 'automator_actions', $callback, 10, 1 );

Description

Fires after all core and integration-specific actions are registered. Developers can use this filter to modify the array of available actions, adding, removing, or altering action data before they are finalized. This hook is crucial for custom action integrations.


Usage

add_filter( 'automator_actions', 'your_function_name', 10, 1 );

Parameters

$this (mixed)
This parameter contains the integrations data that will be filtered.

Return Value

The filtered value.


Examples

add_filter( 'automator_actions', 'my_custom_automator_actions', 10, 1 );

/**
 * Registers a custom action with the Automator plugin.
 *
 * @param array $actions An array of registered Automator actions.
 * @return array The modified array of actions, including the custom one.
 */
function my_custom_automator_actions( $actions ) {
    // Assume $actions is an array of existing action definitions.
    // We'll add our custom action to this array.

    // Define the details for our custom action.
    $custom_action_name = 'send_custom_email_notification';
    $custom_action_label = __( 'Send Custom Email Notification', 'my-text-domain' );
    $custom_action_description = __( 'Sends a personalized email to a specified recipient.', 'my-text-domain' );

    // Add our custom action definition to the array.
    // The exact structure of the action definition will depend on the Automator plugin's requirements.
    // This is a hypothetical representation.
    $actions[ $custom_action_name ] = array(
        'name'        => $custom_action_name,
        'label'       => $custom_action_label,
        'description' => $custom_action_description,
        'options'     => array(
            array(
                'name'        => 'recipient_email',
                'label'       => __( 'Recipient Email', 'my-text-domain' ),
                'type'        => 'text', // Or 'email' if supported
                'required'    => true,
                'description' => __( 'The email address to send the notification to.', 'my-text-domain' ),
            ),
            array(
                'name'        => 'email_subject',
                'label'       => __( 'Email Subject', 'my-text-domain' ),
                'type'        => 'text',
                'required'    => true,
                'description' => __( 'The subject line of the email.', 'my-text-domain' ),
            ),
            array(
                'name'        => 'email_body',
                'label'       => __( 'Email Body', 'my-text-domain' ),
                'type'        => 'textarea',
                'required'    => true,
                'description' => __( 'The main content of the email.', 'my-text-domain' ),
            ),
        ),
        // Potentially add a callback function here if Automator requires it for execution.
        // 'callback' => 'my_automator_execute_custom_email_action',
    );

    return $actions;
}

// If the Automator plugin expects a callback function to execute the action,
// you would define it like this (outside the filter callback):
/*
function my_automator_execute_custom_email_action( $action_data, $trigger_data ) {
    $recipient = $action_data['recipient_email'];
    $subject   = $action_data['email_subject'];
    $body      = $action_data['email_body'];

    // Use WordPress wp_mail() or another suitable method to send the email.
    // You might need to fetch user data or other context from $trigger_data.
    wp_mail( $recipient, $subject, $body );

    // Return true on success, false on failure.
    return true;
}
*/

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/class-automator-functions.php:345
src/api/services/user-selector/class-user-selector-advisor.php:332

public function filter_recipe_parts() {

		$this->integrations = apply_filters_deprecated( 'uap_integrations', array( $this->integrations ), '3.0', 'automator_integrations' );
		$this->integrations = apply_filters( 'automator_integrations', $this->integrations );

		$this->actions = apply_filters_deprecated( 'uap_actions', array( $this->actions ), '3.0', 'automator_actions' );
		$this->actions = apply_filters( 'automator_actions', $this->actions );

		$this->triggers = apply_filters_deprecated( 'uap_triggers', array( $this->triggers ), '3.0', 'automator_triggers' );
		$this->triggers = apply_filters( 'automator_triggers', $this->triggers );

		$this->closures = apply_filters_deprecated( 'uap_closures', array( $this->closures ), '3.0', 'automator_closures' );
		$this->closures = apply_filters( 'automator_closures', $this->closures );

		$this->recipe_items = apply_filters( 'automator_recipe_items', $this->recipe_items );

		$this->all_integrations = apply_filters( 'automator_all_integrations', $this->all_integrations );

		$this->recipe_types = apply_filters_deprecated( 'uap_recipe_types', array( $this->recipe_types ), '3.0', 'automator_recipe_types' );
		$this->recipe_types = apply_filters( 'automator_recipe_types', $this->recipe_types );
	}


Internal Usage

Found in src/core/lib/recipe-parts/actions/abstract-action.php:173:

add_filter( 'automator_actions', array( $this, 'register_action' ) );
Scroll to Top