has_tag()

has_tag()

#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:";

}

#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.

Yes

No

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注