bbp_get_topic_forum_id( $topic_id) ;
		
	 
	
	
	
 
		
			
	
	
		
		Thank you. But how to get the current topic_id. I mean the topic I am viewing? bbp_get_topic_id() is returning 0.
Please help
		
	 
	
	
	
 
		
			
	
	
		
		you’ll need to give me the context – ie what are you trying to do, and what code do you have so far
		
	 
	
	
	
 
		
			
	
	
		
		Okay, here is what I am wanting to do.
if (bbp_get_topic_forum_id(bbp_get_topic_id()) == ‘ID of the Parent forum’){
  do_something;
}
		
	 
	
	
	
 
		
			
	
	
		
		I am writing this code in functions.php and when I am trying to dump data using
print_r (bbp_get_topic_id());
It is returning 0. 
When the above mentioned condition is met I will redirect to another page.
function test_rdr (){
    if (bbp_get_topic_forum_id(bbp_get_topic_id()) == ‘ID of the Parent forum’){
        wp_redirect('/test-page');
        exit;
    }
}
add_action('template_redirect', 'test_rdr')
Please help me to get over with it. 
		
	 
	
	
	
 
		
			
	
	
		
		ok, without getting heavily involved in coding a solution for you (which is my paid day job 🙂  ) I guess that you have hooked to ‘template redirect’ which fires on everypage, so when WordPress displays the test-page it looks again for a value of topic_id, which on the test page does not exist, so returns zero.
if your code is working in that it redirects to test page, then you could try appending the topic id and picking that up in $_REQUEST
eg (untested)
wp_redirect('/test-page/?topic_id='.bbp_get_topic_id());
and then on test page use the code
if (isset($_REQUEST['topic_id'])) $topic_id = $_REQUEST('topic_id') ;