#Overview
This function retrieves all CRM tags currently associated with the user.
#Parameters
wpf_get_tags( $user_id = false, $force = false )
$user_id
(int) (Optional): The user ID to search.$force
(bool) (Optional): Whether to force-refresh the tags.
#Return
(array) $user_tags
The users tags in the CRM.
#Get the current user’s tags
$tags = wpf_get_tags();
#Get the tags for a different user
$tags = wpf_get_tags( $user_id );
#Force an update of the user’s tags by sending an API call to your CRM
In this case the updated tag list will automatically be saved to the local user meta after it’s been retrieved. This example will also force-refresh the user’s contact ID (i.e. it sends two API calls).
$tags = wpf_get_tags( $user_id, true );
#Force an update of the user’s tags without verifying the contact ID
If you’re sure the contact ID is correct, you can also force refresh the tags without looking up the contact ID first, by passing false
as the third parameter.
$tags = wpf_get_tags( $user_id, $force_refresh = true, $lookup_contact_id = false );
#Display the current user’s tags in a list
$tags = wpf_get_tags();
echo '<ul>';
foreach ( $tags as $tag ) {
echo '<li>' . wpf_get_tag_label( $tag ) . '</li>';
}
echo '</ul>';
#Get all available tags
If you want to get all available tags in your CRM, with their names and IDs, you can do so using wpf_get_option()
$available_tags = wpf_get_option( 'available_tags' );
Was this helpful?
Let us know if you liked the post. That’s the only way we can improve.