1.
automator_maybe_parse_token
Sanitize email fields dynamically before they reach a recipe action.
Use case: Users frequently introduce formatting errors like trailing spaces or uppercase letters when registering or filling out forms. External CRMs and newsletter tools are highly sensitive to email syntax, which can lead to failed syncs. Automatically sanitizing token data on the fly prevents these API sync errors.
add_filter('automator_maybe_parse_token', 'ppunch_sanitize_email_tokens', 10, 6);
function ppunch_sanitize_email_tokens($return, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args) {
if (is_string($return) && is_email(trim($return))) {
return strtolower(trim($return));
}
return $return;
}
This filter catches any token value right before it is sent to an active action. By checking if the return is a valid email string, it dynamically forces lowercasing and trims whitespace. You can extend this logic to format dates, clean phone numbers, or modify custom text strings.