automator_bwfan_tag_removed_from_contact
Fires when a tag is removed from a contact, providing access to the removed tags and the contact object.
add_action( 'automator_bwfan_tag_removed_from_contact', $callback, 10, 2 );
Description
Fires when a tag is removed from a contact in Autonami (FluentCRM). Developers can use this hook to trigger custom automations or logic when specific tags are detached from a contact, using the removed tag(s) and the contact object as parameters.
Usage
add_action( 'automator_bwfan_tag_removed_from_contact', 'your_function_name', 10, 2 );
Parameters
-
$tags(mixed) - This parameter contains the tag or tags that were removed from the contact.
-
$bwfcrm_contact_object(mixed) - This parameter contains the tag or tags that were removed from the contact.
Examples
// Example: Log when a tag is removed from a contact and potentially trigger a specific workflow.
add_action( 'automator_bwfan_tag_removed_from_contact', 'my_custom_tag_removed_handler', 10, 2 );
/**
* Handles the 'automator_bwfan_tag_removed_from_contact' action hook.
*
* This function logs the event and checks if the removed tag matches a specific tag
* that should trigger a certain action or workflow.
*
* @param string $tag The tag that was removed from the contact.
* @param object $bwfcrm_contact_object The contact object from which the tag was removed.
* @return void
*/
function my_custom_tag_removed_handler( $tag, $bwfcrm_contact_object ) {
// Ensure we have a valid tag and contact object.
if ( ! $tag || ! is_object( $bwfcrm_contact_object ) || ! isset( $bwfcrm_contact_object->ID ) ) {
error_log( 'my_custom_tag_removed_handler: Invalid parameters received.' );
return;
}
// Log the event for debugging purposes.
$contact_id = $bwfcrm_contact_object->ID;
$contact_email = isset( $bwfcrm_contact_object->email ) ? $bwfcrm_contact_object->email : 'N/A';
error_log( "Tag '{$tag}' removed from contact ID {$contact_id} (Email: {$contact_email})." );
// Example: Trigger a specific Uncanny Automator workflow if a particular tag is removed.
// Replace 'specific_tag_to_watch' with the actual tag you want to monitor.
if ( 'specific_tag_to_watch' === $tag ) {
// In a real-world scenario, you would use Uncanny Automator's API
// to find and trigger a specific recipe. For this example, we'll
// just log another message.
error_log( "Specific tag '{$tag}' removed from contact ID {$contact_id}. Potential workflow trigger." );
// Example of how you might trigger a workflow (this is conceptual and depends on Automator's API)
/*
if ( class_exists( 'UncannyAutomatorUncannyAutomatorSDK' ) ) {
$automator_sdk = new UncannyAutomatorUncannyAutomatorSDK();
$recipe_id = 123; // Replace with the actual ID of your Automator recipe
$user_id = get_user_by_email( $contact_email ) ? get_user_by_email( $contact_email )->ID : null;
if ( $user_id ) {
$automator_sdk->trigger_recipe( $recipe_id, array( 'user_id' => $user_id ) );
error_log( "Attempted to trigger Automator recipe {$recipe_id} for user {$user_id}." );
} else {
error_log( "Could not find WordPress user for contact ID {$contact_id} to trigger recipe {$recipe_id}." );
}
}
*/
}
}
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
uncanny-automator-pro/src/integrations/autonami/add-autonami-integration.php:68
uncanny-automator-pro/src/integrations/autonami/add-autonami-integration.php:73
public function tag_removed_from_contact( $tags, $bwfcrm_contact_object ) {
if ( ! is_array( $tags ) ) {
do_action( 'automator_bwfan_tag_removed_from_contact', $tags, $bwfcrm_contact_object );
return;
}
foreach ( $tags as $tag ) {
do_action( 'automator_bwfan_tag_removed_from_contact', $tag, $bwfcrm_contact_object );
}
}
Internal Usage
Found in uncanny-automator-pro/src/integrations/autonami/triggers/autonami-user-tag-removed.php:47:
$this->add_action( 'automator_bwfan_tag_removed_from_contact' );
Found in uncanny-automator-pro/src/integrations/autonami/triggers/autonami-contact-tag-removed.php:48:
$this->add_action( 'automator_bwfan_tag_removed_from_contact' );