Filter
uncanny-automator-pro
automator_jet_crm_validate_common_triggers_tokens_save_pro
Filters to validate and modify common Jet CRM trigger tokens before saving to ensure data integrity.
add_filter( 'automator_jet_crm_validate_common_triggers_tokens_save_pro', $callback, 10, 1 );
Description
Filters the array of Jet CRM token codes validated during the saving of trigger data in Uncanny Automator Pro. Developers can add custom token codes to this filter to enable validation for new or modified Jet CRM triggers. This hook is essential for extending the integration's functionality with custom token types.
Usage
add_filter( 'automator_jet_crm_validate_common_triggers_tokens_save_pro', 'your_function_name', 10, 1 );
Parameters
-
$args(mixed) - This parameter contains an array of strings representing the types of Jet CRM triggers that are being validated.
Return Value
The filtered value.
Examples
add_filter(
'automator_jet_crm_validate_common_triggers_tokens_save_pro',
'my_custom_jet_crm_trigger_validations',
10,
2
);
/**
* Custom validation for specific JetEngine CRM trigger tokens.
*
* This function allows developers to add or modify the list of JetEngine CRM
* trigger tokens that require specific validation when saving trigger data.
* In this example, we're adding a new token 'JETCRM_CUSTOM_FIELD_UPDATE'
* to the list of tokens that need validation.
*
* @param array $trigger_meta_validations The current array of trigger tokens that require validation.
* @param array $args The arguments passed to the save_token_data function.
* Expected keys: 'trigger_args' and 'entry_args'.
*
* @return array The modified array of trigger tokens that require validation.
*/
function my_custom_jet_crm_trigger_validations( $trigger_meta_validations, $args ) {
// Add a new custom trigger token to the validation list.
// This assumes 'JETCRM_CUSTOM_FIELD_UPDATE' is a custom trigger code
// you've implemented elsewhere that also needs specific parsing.
$trigger_meta_validations[] = 'JETCRM_CUSTOM_FIELD_UPDATE';
// You could also conditionally remove existing validations if needed:
// $trigger_meta_validations = array_diff( $trigger_meta_validations, array( 'JETCRM_TAG_TO_CONTACT' ) );
// Return the modified array of trigger tokens that should undergo validation.
return $trigger_meta_validations;
}
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:146
public function save_token_data( $args, $trigger ) {
if ( ! isset( $args['trigger_args'] ) || ! isset( $args['entry_args']['code'] ) ) {
return;
}
$trigger_meta_validations = apply_filters(
'automator_jet_crm_validate_common_triggers_tokens_save_pro',
array( 'JETCRM_TAG_TO_COMPANY', 'JETCRM_TAG_TO_CONTACT' ),
$args
);
if ( in_array( $args['entry_args']['code'], $trigger_meta_validations ) ) {
list( $tag_id, $object_type, $object_id ) = $args['trigger_args'];
$trigger_log_entry = $args['trigger_entry'];
if ( ! empty( $object_id ) && ! empty( $tag_id ) ) {
Automator()->db->token->save( 'object_id', $object_id, $trigger_log_entry );
Automator()->db->token->save( 'tag_id', $tag_id, $trigger_log_entry );
}
}
}