Filter uncanny-automator-pro

automator_pro_armember_validate_common_trigger_codes

Filters to validate common trigger codes for armember integrations before they are processed.

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

Description

Filters the array of common trigger codes for the ARMember integration. Developers can use this hook to add or remove trigger codes that are considered common, influencing how ARMember triggers are validated.


Usage

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

Parameters

$args (mixed)
This parameter contains an array of strings representing specific trigger codes that are being validated.

Return Value

The filtered value.


Examples

add_filter( 'automator_pro_armember_validate_common_trigger_codes', 'my_custom_armember_trigger_codes', 10, 2 );

/**
 * Adds a custom trigger code validation for the automator_pro_armember_validate_common_trigger_codes hook.
 *
 * This example demonstrates how to add a new valid trigger code 'MY_CUSTOM_CODE'
 * to the list of common trigger codes processed by Uncanny Automator Pro for ARMember.
 *
 * @param array $trigger_codes The array of trigger codes to validate.
 * @param array $args          The arguments passed to the filter.
 *
 * @return array The modified array of trigger codes.
 */
function my_custom_armember_trigger_codes( $trigger_codes, $args ) {
    // Add a custom trigger code to the list of valid codes.
    // For example, if you have a custom ARMember integration that uses a specific code.
    $trigger_codes[] = 'MY_CUSTOM_CODE';

    // You could also conditionally add trigger codes based on $args if needed.
    // For instance, if a specific ARMember plan requires a different trigger code.
    if ( isset( $args['trigger_args']['specific_plan_id'] ) && $args['trigger_args']['specific_plan_id'] === 123 ) {
        $trigger_codes[] = 'ANOTHER_CUSTOM_CODE_FOR_PLAN_123';
    }

    return $trigger_codes;
}

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/armember/tokens/armember-pro-tokens.php:70

public function save_token_data( $args, $trigger ) {
		if ( ! isset( $args['trigger_args'] ) || ! isset( $args['entry_args']['code'] ) ) {
			return;
		}

		$trigger_meta_validations = apply_filters(
			'automator_pro_armember_validate_common_trigger_codes',
			array( 'ARM_PLAN_EXPIRES' ),
			$args
		);

		if ( in_array( $args['entry_args']['code'], $trigger_meta_validations ) ) {
			$trigger_log_entry = $args['trigger_entry'];
			if ( isset( $args['trigger_args'][0], $args['trigger_args'][1] ) ) {
				Automator()->db->token->save( 'save_user_id', $args['trigger_args'][0]['user_id'], $trigger_log_entry );
				Automator()->db->token->save( 'save_plan_id', $args['trigger_args'][0]['plan_id'], $trigger_log_entry );
			}
		}
	}


Scroll to Top