Action uncanny-automator

automator_autonami_save_tokens

Fires after Autonami saves tokens, providing access to save data, contact, trigger code, and log entry.

add_action( 'automator_autonami_save_tokens', $callback, 10, 4 );

Description

Fires after Autonami contact tokens are saved. Developers can use this hook to perform custom actions or modify token data before it's finalized, potentially influencing subsequent automation steps. It provides access to the saved data, the contact object, trigger code, and log entry.


Usage

add_action( 'automator_autonami_save_tokens', 'your_function_name', 10, 4 );

Parameters

$data (mixed)
This parameter contains the trigger arguments passed to the hook.
$bwfcrm_contact (mixed)
This parameter holds the data associated with the trigger being processed.
$trigger_code (mixed)
This parameter, `$bwfcrm_contact`, likely holds information related to the CRM contact associated with the current trigger event.
$log_entry (mixed)
This parameter holds the unique code identifier for the trigger that is currently being processed.

Examples

add_action( 'automator_autonami_save_tokens', 'my_custom_autonami_token_saver', 10, 4 );

/**
 * Saves custom token data when Autonami tokens are saved.
 *
 * This function demonstrates how to hook into the 'automator_autonami_save_tokens' action
 * to perform custom actions based on the provided token data.
 *
 * @param mixed $data The main data array passed to the action.
 * @param mixed $bwfcrm_contact The BWFCRM_Contact object.
 * @param mixed $trigger_code The code of the trigger.
 * @param mixed $log_entry The log entry object.
 */
function my_custom_autonami_token_saver( $data, $bwfcrm_contact, $trigger_code, $log_entry ) {

    // Example: Log additional details if the trigger code is specific
    if ( 'some_specific_trigger' === $trigger_code && $bwfcrm_contact instanceof BWFCRM_Contact ) {

        // Access properties of the BWFCRM_Contact object
        $contact_email = $bwfcrm_contact->get_email();
        $contact_id    = $bwfcrm_contact->get_id();

        // You could perform various actions here, like:
        // 1. Saving custom meta data for the contact.
        // 2. Sending a notification to an admin.
        // 3. Triggering another internal process.

        // For demonstration, let's just log some information
        error_log( sprintf(
            'Custom Autonami Token Save: Trigger "%s" for Contact ID %d (Email: %s). Data: %s',
            $trigger_code,
            $contact_id,
            $contact_email,
            print_r( $data, true )
        ) );
    }

    // If this were a filter, you'd return a value:
    // return $modified_data;
}

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/autonami/tokens/autonami-tokens.php:314

public function save_token_data( $args, $trigger ) {

		if ( 'AUTONAMI' !== $trigger->get_integration() ) {
			return;
		}

		if ( ! isset( $args['trigger_args'] ) || ! isset( $args['entry_args']['code'] ) ) {
			return;
		}

		$trigger_code = $args['entry_args']['code'];

		$log_entry = $args['trigger_entry'];

		$data = array_shift( $args['trigger_args'] );

		if ( in_array( $trigger_code, $this->get_list_triggers(), true ) ) {

			if ( $data instanceof BWFCRM_Lists ) {
				$this->save_list_tokens( $data, $log_entry );
			}
		}

		if ( in_array( $trigger_code, $this->get_tag_triggers(), true ) ) {

			if ( $data instanceof BWFCRM_Tag ) {
				$this->save_tag_tokens( $data, $log_entry );
			}
		}

		$bwfcrm_contact = array_shift( $args['trigger_args'] );

		if ( $bwfcrm_contact instanceof BWFCRM_Contact ) {
			$this->save_contact_tokens( $bwfcrm_contact, $log_entry );
		}

		do_action( 'automator_autonami_save_tokens', $data, $bwfcrm_contact, $trigger_code, $log_entry );

	}

Internal Usage

Found in uncanny-automator-pro/src/integrations/autonami/tokens/autonami-pro-tokens.php:21:

add_filter( 'automator_autonami_save_tokens', array( $this, 'save_token_data' ), 10, 5 );
Scroll to Top