Problem with bbp_is_forum_category function
-
Hi there,
I’m trying to write some advanced search functions for BBpress. One of these should let people search only in the forum or subforum they currenty are in. I followed several examples posted on the net and tried to refine them myself.
Unfortunately, I am experiencing a problem with the bbp_forum_get_subforums fuction.
The fuction I am writing should be able to get the list of subforums present in a category type forum when the search is fired from a category type forum.
The code is as follows://If the forum is a category, then search in all the subforums if( bbp_is_forum_category($forum_id)){ $sub_forums = bbp_forum_get_subforums($forum_id); $subforum_id = array_column($sub_forums,'ID'); $min_subforums = min($subforum_id); $max_subforums = max($subforum_id); $r['meta_query'] = array( array( 'key' => '_bbp_forum_id', 'value' => array($min_subforums,$max_subforums), 'compare' => 'BETWEEN', ) ); }
Unfortunately, bbp_forum_get_subforums($forum_id) gives a false result.
Strangely enough, if I try to put the same code in a fuction and add it with “add_action” to a forum page, it gives me the corret list of subforums if the current forum is a category.
Can someone please help me addressing this problem? I am using the latest version of WP and BBpress.
- You must be logged in to reply to this topic.