Filter uncanny-automator-pro

automator_do_action_parse_vars

Filters the parsed output value. Filters the parsed output value for custom actions, allowing modification of the final result before it's used.

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

Description

Allows modification of the final parsed output value before it's used in a custom action. Developers can alter the resolved dynamic content or function results by returning a modified value. This hook is ideal for sanitizing, transforming, or adding context to action outputs.


Usage

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

Parameters

$output (mixed)
The final parsed value.
$value (mixed)
The original input value.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to use the 'automator_do_action_parse_vars' filter to modify a parsed value.
 *
 * This example checks if the original input value is a string containing a specific keyword.
 * If it is, it appends a timestamp to the parsed output.
 */
add_filter( 'automator_do_action_parse_vars', function( $output, $value ) {

	// Check if the original value is a string and contains 'special_keyword'
	if ( is_string( $value ) && strpos( $value, 'special_keyword' ) !== false ) {

		// Append a timestamp to the output if the condition is met
		$output = $output . ' - ' . date( 'Y-m-d H:i:s' );

	}

	// Always return the (potentially modified) output
	return $output;

}, 10, 2 ); // Priority 10, accepts 2 arguments ($output, $value)

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/integrations/custom-action/actions/run-do-action.php:155
uncanny-automator-pro/src/integrations/run-code/actions/run-code-do-action-everyone.php:143
uncanny-automator-pro/src/integrations/run-code/actions/run-code-call-function-everyone.php:179
uncanny-automator-pro/src/integrations/run-code/actions/run-code-call-function.php:141
uncanny-automator-pro/src/integrations/run-code/actions/run-code-do-action.php:128

protected function parse( $value ) {

		$output = null;

		switch ( $value ) {
			case 'null':
				break;
			case 'array()':
			case '[]':
				$output = array();
				break;
			default:
				$output = $value;
				break;
		}

		/**
		 * Filters the parsed output value.
		 *
		 * @param mixed $output The final parsed value.
		 * @param mixed $value  The original input value.
		 */
		return apply_filters( 'automator_do_action_parse_vars', $output, $value );
	}

Scroll to Top