remove_tags()

Overview

This function allows you to remove an array of tags (using tag IDs) from a user.

Remove tags from the current user

$tags = array(123, 456, 789);
wp_fusion()->user->remove_tags( $tags );

Remove tags from a specific user ID

$tags = array(123, 456, 789);
wp_fusion()->user->remove_tags( $tags, $user_id );

The function will return true if the tags were removed successfully, and false if there was a connection error or the user wasn’t found in the CRM. Any errors will be logged to the WP Fusion Logs.

Examples

Remove a tag when another tag is applied

WP Fusion includes a lot of interfaces for applying tags, but because removing tags is less common most of our integrations don’t include options for removing tags.

This example removes the tag Pending Signup when the tag Profile Complete is applied.

function remove_pending_signup_tag( $user_id, $tags_applied ) {

	$tag_to_check  = wpf_get_tag_id( 'Profile Complete' );
	$tag_to_remove = wpf_get_tag_id( 'Pending Signup' );

	if ( in_array( $tag_to_check, $tags_applied ) ) {
		wp_fusion()->user->remove_tags( array( $tag_to_remove ), $user_id );
	}

}

add_action( 'wpf_tags_applied', 'remove_pending_signup_tag', 10, 2 );

Was this helpful?