Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
AC_TOKENS::save_token_data( mixed $args, mixed $trigger )

save_token_data


Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Parameters Parameters

$args

(Required)

$trigger

(Required)


Top ↑

Return Return

(void)


Source Source

File: src/integrations/active-campaign/tokens/ac-tokens.php

	public function save_token_data( $args, $trigger ) {
		if ( 'ACTIVE_CAMPAIGN' !== $trigger->get_integration() ) {
			return;
		}
		if ( ! isset( $args['trigger_args'] ) || ! isset( $args['entry_args']['code'] ) ) {
			return;
		}
		$trigger_code = $args['entry_args']['code'];
		if ( 'CONTACT_TAG_ADDED' === $trigger_code || 'CONTACT_TAG_REMOVED' === $trigger_code ) {
			$ac_event = array_shift( $args['trigger_args'] );
			$trigger_log_entry = $args['trigger_entry'];
			if ( ! empty( $ac_event['tag'] ) ) {
				Automator()->db->token->save( 'TAG', $ac_event['tag'], $trigger_log_entry );
			}
			if ( ! empty( $ac_event['contact']['email'] ) ) {
				Automator()->db->token->save( 'EMAIL', $ac_event['contact']['email'], $trigger_log_entry );
			}
			if ( ! empty( $ac_event['contact']['tags'] ) ) {
				Automator()->db->token->save( 'TAGS', $ac_event['contact']['tags'], $trigger_log_entry );
			}
			if ( ! empty( $ac_event['contact']['first_name'] ) ) {
				Automator()->db->token->save( 'FIRST_NAME', $ac_event['contact']['first_name'], $trigger_log_entry );
			}
			if ( ! empty( $ac_event['contact']['last_name'] ) ) {
				Automator()->db->token->save( 'LAST_NAME', $ac_event['contact']['last_name'], $trigger_log_entry );
			}
			if ( ! empty( $ac_event['contact']['phone'] ) ) {
				Automator()->db->token->save( 'PHONE', $ac_event['contact']['phone'], $trigger_log_entry );
			}
			if ( ! empty( $ac_event['contact']['customer_acct_name'] ) ) {
				Automator()->db->token->save( 'CUSTOMER_ACCT_NAME', $ac_event['contact']['customer_acct_name'], $trigger_log_entry );
			}
		}
	}