automator_wp_mail_smtp_validate_trigger_meta_pieces
Filters WP Mail SMTP trigger meta pieces during validation to allow customization and manipulation.
add_filter( 'automator_wp_mail_smtp_validate_trigger_meta_pieces', $callback, 10, 1 );
Description
Filters the metadata pieces used to validate WP Mail SMTP triggers. Allows developers to modify or add validation rules for trigger metadata, ensuring correct data is passed and processed within Uncanny Automator's WP Mail SMTP integration.
Usage
add_filter( 'automator_wp_mail_smtp_validate_trigger_meta_pieces', 'your_function_name', 10, 1 );
Parameters
-
$args(mixed) - This parameter contains an array of specific subject codes that are used for validation within the WP Mail SMTP integration.
Return Value
The filtered value.
Examples
/**
* Example function to hook into 'automator_wp_mail_smtp_validate_trigger_meta_pieces'.
*
* This function adds custom validation logic for specific WP Mail SMTP trigger meta pieces.
* It checks if a specific trigger code is present in the provided arguments
* and potentially modifies the validation array or performs other actions.
*
* @param array $trigger_meta_validations An array of trigger meta codes to validate.
* @param array $args The arguments passed from the trigger.
*
* @return array The modified or original array of trigger meta codes to validate.
*/
function my_automator_wp_mail_smtp_validation( $trigger_meta_validations, $args ) {
// Example: If the trigger code is 'MY_CUSTOM_EMAIL_SENT', add it to the validation list.
// This assumes $args['entry_args']['code'] contains the current trigger code.
if ( isset( $args['entry_args']['code'] ) && 'MY_CUSTOM_EMAIL_SENT' === $args['entry_args']['code'] ) {
// Add our custom code to the list of validations.
$trigger_meta_validations[] = 'MY_CUSTOM_EMAIL_SENT';
}
// Example: If the trigger code is 'ANOTHER_EMAIL_EVENT', add a specific subject code for it.
if ( isset( $args['entry_args']['code'] ) && 'ANOTHER_EMAIL_EVENT' === $args['entry_args']['code'] ) {
// Ensure 'SPECIFIC_SUBJECT_CODE' is only added if this trigger event requires it.
if ( ! in_array( 'SPECIFIC_SUBJECT_CODE', $trigger_meta_validations, true ) ) {
$trigger_meta_validations[] = 'SPECIFIC_SUBJECT_CODE';
}
}
// Return the (potentially modified) array of meta pieces to validate.
return $trigger_meta_validations;
}
add_filter( 'automator_wp_mail_smtp_validate_trigger_meta_pieces', 'my_automator_wp_mail_smtp_validation', 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/wp-mail-smtp-pro/tokens/wpmsmtp-tokens.php:45
src/integrations/wp-mail-smtp-pro/tokens/wpmsmtp-tokens.php:71
src/integrations/wp-mail-smtp-pro/tokens/wpmsmtp-tokens.php:160
uncanny-automator-pro/src/integrations/wp-mail-smtp-pro/tokens/wpmsmtp-pro-tokens.php:97
public function save_token_data( $args, $trigger ) {
if ( ! isset( $args['trigger_args'] ) || ! isset( $args['entry_args']['code'] ) ) {
return;
}
$trigger_meta_validations = apply_filters(
'automator_wp_mail_smtp_validate_trigger_meta_pieces',
array( 'SPECIFIC_SUBJECT_CODE' ),
$args
);
if ( in_array( $args['entry_args']['code'], $trigger_meta_validations, true ) ) {
$email_tracking_details = array_shift( $args['trigger_args'] );
$trigger_log_entry = $args['trigger_entry'];
if ( ! empty( $email_tracking_details ) ) {
Automator()->db->token->save( 'tracking_data', maybe_serialize( $email_tracking_details ), $trigger_log_entry );
}
}
}