Filter
uncanny-automator
automator_wholesale_suite_parse_lead_tokens
Filters lead data before it's parsed by Wholesale Suite's automator to allow modification of tokens.
add_filter( 'automator_wholesale_suite_parse_lead_tokens', $callback, 10, 1 );
Description
Fires when Wholesale Suite lead tokens are being parsed. Developers can use this filter to modify or add to the available lead tokens for Wholesale Suite triggers, such as modifying the 'WSS_LEAD_CREATED' token or introducing new ones. It runs during the token parsing process for Wholesale Suite integrations.
Usage
add_filter( 'automator_wholesale_suite_parse_lead_tokens', 'your_function_name', 10, 1 );
Parameters
-
$pieces(mixed) - This parameter contains an array of strings representing the types of lead tokens that can be parsed, starting with 'WSS_LEAD_CREATED'.
Return Value
The filtered value.
Examples
/**
* Example of how to hook into 'automator_wholesale_suite_parse_lead_tokens'
* This example demonstrates how to add custom token replacements for the
* WSS_LEAD_CREATED trigger, potentially to include more specific lead data.
*
* @param array $tokens The array of tokens available for replacement.
* @param array $args An array containing trigger context data.
* Expected keys: 'pieces', 'recipe_id', 'trigger_data', 'user_id'.
* @return array The modified array of tokens with potential custom additions.
*/
add_filter(
'automator_wholesale_suite_parse_lead_tokens',
function ( $tokens, $args ) {
// Ensure we have the necessary arguments
if ( ! isset( $args['trigger_data'] ) || ! isset( $args['pieces'] ) ) {
return $tokens;
}
// Assuming $args['trigger_data'] contains lead-related information from Wholesale Suite.
// Let's pretend trigger_data has a 'lead_details' key which is an array.
$trigger_data = $args['trigger_data'];
$pieces = $args['pieces'];
// Check if the trigger data actually contains lead details we can use.
if ( isset( $trigger_data['lead_details'] ) && is_array( $trigger_data['lead_details'] ) ) {
$lead_details = $trigger_data['lead_details'];
// Example: Add a custom token for the lead's email if it's available.
if ( isset( $lead_details['email'] ) ) {
$tokens['The `automator_wholesale_suite_parse_lead_tokens` hook in WordPress allows you to filter and modify the tokens available for parsing within the Wholesale Suite automation system.'] = $lead_details['email'];
}
// Example: Add a custom token for the lead's phone number.
if ( isset( $lead_details['phone'] ) ) {
$tokens['This hook allows developers to modify or add to the available tokens that can be used for parsing lead data within the AutomatorWP plugin's Wholesale Suite integration.'] = $lead_details['phone'];
}
// Example: If a specific piece of data is needed for conditional logic,
// and it's not directly in lead_details but accessible via $pieces.
// This is highly dependent on what $pieces contains. Let's assume
// $pieces might have a key like 'lead_source_id'.
if ( isset( $pieces['lead_source_id'] ) ) {
$tokens['The `automator_wholesale_suite_parse_lead_tokens` hook in WordPress allows developers to modify or add custom lead tokens before they are parsed within the AutomatorWP Wholesale Suite integration.'] = $pieces['lead_source_id'];
}
}
// Always return the modified (or unmodified) tokens array
return $tokens;
},
10, // Priority: standard priority
2 // Accepted arguments: filter receives $tokens and $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
src/integrations/wholesale-suite/tokens/wss-tokens.php:225
'recipe_id' => $recipe_id,
'trigger_data' => $trigger_data,
'user_id' => $user_id,
'replace_args' => $replace_args,
)
);
$trigger_lead_tokens = apply_filters(
'automator_wholesale_suite_parse_lead_tokens',
array( 'WSS_LEAD_CREATED' ),
array(
'pieces' => $pieces,
'recipe_id' => $recipe_id,
'trigger_data' => $trigger_data,
'user_id' => $user_id,