apply_tags()

#Overview

This function allows you to apply an array of tags to a user.

The function expects an array of tag IDs. Some CRM’s, like Infusionsoft, Ontraport, and ConvertKit use internal tag IDs to designate their tags. Other CRMs, like ActiveCampaign, Drip, AgileCRM, and Mautic don’t use tag IDs, and a tag label is sufficient.

If you’re unsure, you can always use get_tag_id() to get the appropriate tag ID for this function:

$tag_id = wp_fusion()->user->get_tag_id( 'Tag Name' );

#Parameters

apply_tags( $tags, $user_id = false )
  • $tags (array) (Required): The array of tags to apply to a user.
  • $user_id (int) (Optional): The user ID to apply the tags to.

#Return

(bool) The success status.

#Apply tags to the current user (Infusionsoft and others which use tag IDs)

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

#Apply tags to the current user (ActiveCampaign and others which don’t use tag IDs)

$tags = array('Tag One', 'Tag Two', 'Tag Three');
wp_fusion()->user->apply_tags( $tags );

#Apply tags to a specific user ID

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

The function will return true if the tags were applied successfully, and false if there was a connection error or the user wasn’t found in the CRM.

Was this helpful?