Filter
uncanny-automator-pro
automator_jet_crm_validate_common_pro_triggers_tokens_parse
Filters Jet CRM trigger tokens, allowing modification of available trigger options before they are parsed.
add_filter( 'automator_jet_crm_validate_common_pro_triggers_tokens_parse', $callback, 10, 1 );
Description
Filters the validated common JetEngine CRM trigger tokens before parsing them for Automator Pro recipes. Developers can use this to add or remove trigger token identifiers, customize validation logic, or modify the array of tokens processed. This hook is essential for extending or restricting JetEngine CRM trigger support within Automator Pro.
Usage
add_filter( 'automator_jet_crm_validate_common_pro_triggers_tokens_parse', 'your_function_name', 10, 1 );
Parameters
-
$pieces(mixed) - This parameter contains an array of strings representing the specific JetCRM trigger types that the function is intended to validate or process.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the automator_jet_crm_validate_common_pro_triggers_tokens_parse filter.
*
* This example demonstrates how to add a custom validation rule for JetCRM Pro triggers
* to ensure that only specific JetCRM trigger types are processed.
*/
add_filter(
'automator_jet_crm_validate_common_pro_triggers_tokens_parse',
function ( $trigger_meta_validations, $replacement_args ) {
// Example: If the trigger is not one of the allowed types, remove it from validation.
// This could be useful if you have a custom JetCRM trigger that shouldn't have its tokens parsed.
if ( ! in_array( $trigger_meta_validations[0], array( 'JETCRM_QUOTE_CREATED', 'JETCRM_QUOTE_ACCEPTED', 'JETCRM_INVOICE_CREATED', 'JETCRM_TAGS' ) ) ) {
return array(); // Return an empty array to indicate no validation needed for this trigger type.
}
// Example: Add a custom validation rule for a specific trigger.
if ( $trigger_meta_validations[0] === 'JETCRM_TAGS' ) {
// Let's say we want to ensure the tag ID is a positive integer.
$tag_id = isset( $replacement_args['pieces'][1] ) ? intval( $replacement_args['pieces'][1] ) : 0;
if ( $tag_id <= 0 ) {
// If the tag ID is invalid, we might want to prevent token replacement.
// For this example, we'll just log an error and allow it to proceed,
// but in a real scenario, you might return an empty array or throw an exception.
error_log( 'Invalid JetCRM TAG ID provided for recipe ID: ' . $replacement_args['recipe_id'] );
}
}
// Always return the potentially modified array of trigger meta validations.
return $trigger_meta_validations;
},
10, // Priority
2 // Accepted arguments: $trigger_meta_validations, $replacement_args
);
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/jet-crm/tokens/jetcrm-pro-tokens.php:455
*/
public function parse_jetcrm_pro_tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
if ( ! is_array( $pieces ) || ! isset( $pieces[1] ) || ! isset( $pieces[2] ) ) {
return $value;
}
$trigger_meta_validations = apply_filters(
'automator_jet_crm_validate_common_pro_triggers_tokens_parse',
array( 'JETCRM_QUOTE_CREATED', 'JETCRM_QUOTE_ACCEPTED', 'JETCRM_INVOICE_CREATED', 'JETCRM_TAGS' ),
array(
'pieces' => $pieces,
'recipe_id' => $recipe_id,
'trigger_data' => $trigger_data,
'user_id' => $user_id,