Conditional Statement Based on Forum ID
-
I’m trying to write a conditional statement to auto tag new topics based on forum.
This is what I have so far
add_action ( 'bbp_insert_topic', 'myprefix_assign_tag_to_post' , 10, 1 ); add_action ( 'bbp_new_topic', 'myprefix_assign_tag_to_post', 10, 1 ); add_action ( 'bbp_edit_topic', 'myprefix_assign_tag_to_post', 10, 1 ); function myprefix_assign_tag_to_post($topic_id) { if( bbp_is_forum ( '168' ) && bbp_current_user_can_publish_topics() ) { wp_set_post_terms( $topic_id, 'introductions', 'topic-tag', true ); } elseif( bbp_is_forum ( '1343' ) && bbp_current_user_can_publish_topics() ) { wp_set_post_terms( $topic_id, 'discovery', 'topic-tag', true ); } }
The problem is, this automatically tags the new topics with “Introductions” regardless of the forum. I tried replacing ‘bbp_is_forum’ with ‘bbp_is_single_forum’, and the same thing happens. I’ve tried replacing it with ‘bbp_is_forum_archive’ and nothing happens. I’ve even tried replacing the ID with slug, with and without the single quotes, trying it with just one IF statement, and I’m not getting the desired results.
I also tried using is_page, hoping it would be using the default WordPress call since it used in the functions.php for topics. No joy.
So, if someone could please tell me what I should be using instead of is_forum, is_single_forum, is_etc, that would be great.
- You must be logged in to reply to this topic.