#Overview
This function determines whether a user has a given tag. A tag ID or label can be provided.
if ( wpf_has_tag( 'Paying Customer' ) ) {
echo "Thanks for your payment!";
}
Or more complex conditions can be created by combining calls to has_tag()
, for example:
if ( wpf_has_tag( 'New Customer' ) && ! wpf_has_tag( 'Watched Intro Video' ) ) {
echo "Welcome to our site! Please watch our introduction video here:";
}
#Parameters
has_tag( $tags, $user_id = false )
$tags
(mixed) (Required): The tag or tags.$user_id
(int) (Optional): The user ID to check the tags of.
#Return
(bool) Whether the user has the tag
#By User ID
To check the tags for a specific user, pass a $user_id
as the second parameter:
if ( wpf_has_tag( 'Paying Customer', $user_id ) ) {
echo "Thanks for your payment!";
}
#Array Syntax
The function also accepts an array of tag names or IDs. If the user has any of the provided tags the function will return true
.
if ( wpf_has_tag( array( 'Pending Affiliate', 'Accepted Affiliate' ) ) {
echo "Thanks for joining our affiliate program!";
}
Was this helpful?
Let us know if you liked the post. That’s the only way we can improve.