bbp_is_forum_closed

Is the forum closed?.

Description

bbp_is_forum_closed( (int) $forum_id = 0, (bool) $check_ancestors = true ); 

Parameters (2)

0. $forum_id — Optional. (int)
Forum id
1. $check_ancestors — Optional. (bool) => true
Check if the ancestors are closed (only if they're a category)

Usage

  1. if ( !function_exists( 'bbp_is_forum_closed' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/template.php'; 
  3.  
  4. // Optional. Forum id 
  5. $forum_id = -1; 
  6.  
  7. // Check if the ancestors are closed (only 
  8. // if they're a category) 
  9. $check_ancestors = true; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bbp_is_forum_closed($forum_id, $check_ancestors); 
  13.  

Defined (1)

The function is defined in the following location(s).

/includes/forums/template.php  
  1. function bbp_is_forum_closed( $forum_id = 0, $check_ancestors = true ) { 
  2.  
  3. $forum_id = bbp_get_forum_id( $forum_id ); 
  4. $retval = ( bbp_get_closed_status_id() === bbp_get_forum_status( $forum_id ) ); 
  5.  
  6. if ( !empty( $check_ancestors ) ) { 
  7. $ancestors = bbp_get_forum_ancestors( $forum_id ); 
  8.  
  9. foreach ( (array) $ancestors as $ancestor ) { 
  10. if ( bbp_is_forum_category( $ancestor, false ) && bbp_is_forum_closed( $ancestor, false ) ) { 
  11. $retval = true; 
  12.  
  13. return (bool) apply_filters( 'bbp_is_forum_closed', (bool) $retval, $forum_id, $check_ancestors );