bbp_is_forum_hidden

Is the forum hidden?.

Description

bbp_is_forum_hidden( (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 private (only if they're a category)

Usage

  1. if ( !function_exists( 'bbp_is_forum_hidden' ) ) { 
  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 private (only if 
  8. // they're a category) 
  9. $check_ancestors = true; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bbp_is_forum_hidden($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_hidden( $forum_id = 0, $check_ancestors = true ) { 
  2.  
  3. $forum_id = bbp_get_forum_id( $forum_id ); 
  4. $visibility = bbp_get_forum_visibility( $forum_id ); 
  5.  
  6. // If post status is private, return true 
  7. $retval = ( bbp_get_hidden_status_id() === $visibility ); 
  8.  
  9. // Check ancestors and inherit their privacy setting for display 
  10. if ( !empty( $check_ancestors ) ) { 
  11. $ancestors = bbp_get_forum_ancestors( $forum_id ); 
  12.  
  13. foreach ( (array) $ancestors as $ancestor ) { 
  14. if ( bbp_is_forum( $ancestor ) && bbp_is_forum_hidden( $ancestor, false ) ) { 
  15. $retval = true; 
  16.  
  17. return (bool) apply_filters( 'bbp_is_forum_hidden', (bool) $retval, $forum_id, $check_ancestors );