Filter
uncanny-automator
automator_jet_crm_validate_common_possible_triggers_tokens
Filters possible trigger tokens for Jet CRM automation, allowing modification of the default list.
add_filter( 'automator_jet_crm_validate_common_possible_triggers_tokens', $callback, 10, 1 );
Description
This filter hook allows developers to modify the list of valid trigger tokens for Jet Engine CRM integrations. It fires when defining possible triggers and can be used to add or remove trigger codes. The default list includes `JETCRM_CONTACT_CREATED` and `JETCRM_CONTACT_STATUS_UPDATED`.
Usage
add_filter( 'automator_jet_crm_validate_common_possible_triggers_tokens', 'your_function_name', 10, 1 );
Parameters
-
$args(mixed) - This parameter contains an array of possible trigger codes that can be validated for JetCRM.
Return Value
The filtered value.
Examples
/**
* Example of adding a filter to automator_jet_crm_validate_common_possible_triggers_tokens.
* This example demonstrates how to add a new trigger code to the list of
* validated common triggers for Jet CRM integrations within the Automator plugin.
*
* @param array $trigger_codes The array of common trigger codes to validate.
* @param array $args Additional arguments passed to the filter, including trigger meta.
*
* @return array The modified array of trigger codes.
*/
function my_automator_jet_crm_validate_triggers( $trigger_codes, $args ) {
// Assume we want to also validate a hypothetical 'JETCRM_LEAD_ADDED' trigger code
// if it's a relevant context.
// For demonstration, let's say we only add it if a specific flag is present in $args.
if ( isset( $args['some_custom_flag'] ) && true === $args['some_custom_flag'] ) {
$trigger_codes[] = 'JETCRM_LEAD_ADDED';
}
// You could also remove existing trigger codes if needed, e.g.:
// $trigger_codes = array_diff( $trigger_codes, array( 'JETCRM_CONTACT_CREATED' ) );
return $trigger_codes;
}
// Add the filter to WordPress, ensuring the callback function accepts the correct number of arguments.
// The original apply_filters call passes 2 arguments, so our callback should accept 2.
add_filter( 'automator_jet_crm_validate_common_possible_triggers_tokens', 'my_automator_jet_crm_validate_triggers', 10, 2 );
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/integrations/jet-crm/tokens/jetcrm-tokens.php:70
* @param array $args
*
* @return array|array[]|mixed
*/
public function jetcrm_possible_tokens( $tokens = array(), $args = array() ) {
$trigger_code = $args['triggers_meta']['code'];
$trigger_meta_validations = apply_filters(
'automator_jet_crm_validate_common_possible_triggers_tokens',
array( 'JETCRM_CONTACT_CREATED', 'JETCRM_CONTACT_STATUS_UPDATED' ),
$args
);
if ( in_array( $trigger_code, $trigger_meta_validations, true ) ) {