Action uncanny-automator

automator_bwfan_contact_added_to_list

Fires when a contact is added to a list within the Autonami integration.

add_action( 'automator_bwfan_contact_added_to_list', $callback, 10, 2 );

Description

Fires after a contact is added to one or more Autonami lists. Developers can use this hook to trigger custom actions, update contact data, or integrate with other services when a contact enters a specific list. It passes the list(s) the contact was added to and the contact object itself.


Usage

add_action( 'automator_bwfan_contact_added_to_list', 'your_function_name', 10, 2 );

Parameters

$lists (mixed)
This parameter contains information about the lists the contact was added to.
$bwfcrm_contact_object (mixed)
This parameter contains the list or lists that the contact has been added to.

Examples

add_action( 'automator_bwfan_contact_added_to_list', function( $list_id, $contact_object ) {
	// Example: Log the contact being added to a specific list.
	// In a real scenario, you might trigger an email, update a custom field,
	// or interact with another CRM or automation tool.

	// Ensure we have a valid contact object and list ID
	if ( ! is_object( $contact_object ) || empty( $list_id ) ) {
		// Log an error or warning if data is insufficient
		error_log( 'automator_bwfan_contact_added_to_list: Missing contact object or list ID.' );
		return;
	}

	// Get contact details (assuming $contact_object has properties like 'email' and 'first_name')
	$contact_email = isset( $contact_object->email ) ? $contact_object->email : 'N/A';
	$contact_name  = isset( $contact_object->first_name ) ? $contact_object->first_name : '';

	// Get list name (this might require a separate function or lookup depending on how lists are managed)
	// For this example, we'll assume $list_id is sufficient or we have a way to get the name.
	// Let's simulate getting a list name for demonstration.
	$list_name = "List {$list_id}"; // Replace with actual list name retrieval if possible

	// Log the event
	$log_message = sprintf(
		'Contact "%s" (%s) was added to list "%s" (ID: %d).',
		esc_html( $contact_name ),
		esc_html( $contact_email ),
		esc_html( $list_name ),
		absint( $list_id )
	);

	// You could save this to a custom log file, a database table,
	// or use WordPress's built-in error logging.
	error_log( $log_message );

	// Example: If the list ID is '123', trigger a specific automation.
	if ( '123' === $list_id ) {
		// This is where you'd add logic to trigger a specific automation sequence.
		// For instance, calling a function that starts a campaign.
		// Example: send_welcome_email_to_new_subscriber( $contact_object );
		error_log( "Triggering special automation for list ID {$list_id} for contact {$contact_email}." );
	}

}, 10, 2 ); // Priority 10, accepting 2 arguments

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/add-autonami-integration.php:57
src/integrations/autonami/add-autonami-integration.php:62

public function contact_added_to_lists( $lists, $bwfcrm_contact_object ) {

		if ( ! is_array( $lists ) ) {
			do_action( 'automator_bwfan_contact_added_to_list', $lists, $bwfcrm_contact_object );
			return;
		}

		foreach ( $lists as $list ) {
			do_action( 'automator_bwfan_contact_added_to_list', $list, $bwfcrm_contact_object );
		}

	}


Internal Usage

Found in src/integrations/autonami/triggers/autonami-user-added-to-list.php:48:

$this->add_action( 'automator_bwfan_contact_added_to_list' );

Found in src/integrations/autonami/triggers/autonami-contact-added-to-list.php:49:

$this->add_action( 'automator_bwfan_contact_added_to_list' );
Scroll to Top