bbp_publicize_forum

Mark the forum as public.

Description

bbp_publicize_forum( (int) $forum_id = 0, (string) $current_visibility = '' ); 

Parameters (2)

0. $forum_id — Optional. (int)
Forum id
1. $current_visibility — Optional. (string) => ''
The current visibility.

Usage

  1. if ( !function_exists( 'bbp_publicize_forum' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/functions.php'; 
  3.  
  4. // Optional. Forum id 
  5. $forum_id = -1; 
  6.  
  7. // The current visibility. 
  8. $current_visibility = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_publicize_forum($forum_id, $current_visibility); 
  12.  

Defined (1)

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

/includes/forums/functions.php  
  1. function bbp_publicize_forum( $forum_id = 0, $current_visibility = '' ) { 
  2.  
  3. $forum_id = bbp_get_forum_id( $forum_id ); 
  4.  
  5. do_action( 'bbp_publicize_forum', $forum_id ); 
  6.  
  7. // Get private forums 
  8. $private = bbp_get_private_forum_ids(); 
  9.  
  10. // Find this forum in the array 
  11. if ( in_array( $forum_id, $private ) ) { 
  12.  
  13. $offset = array_search( $forum_id, $private ); 
  14.  
  15. // Splice around it 
  16. array_splice( $private, $offset, 1 ); 
  17.  
  18. // Update private forums minus this one 
  19. update_option( '_bbp_private_forums', array_unique( array_filter( array_values( $private ) ) ) ); 
  20.  
  21. // Get hidden forums 
  22. $hidden = bbp_get_hidden_forum_ids(); 
  23.  
  24. // Find this forum in the array 
  25. if ( in_array( $forum_id, $hidden ) ) { 
  26.  
  27. $offset = array_search( $forum_id, $hidden ); 
  28.  
  29. // Splice around it 
  30. array_splice( $hidden, $offset, 1 ); 
  31.  
  32. // Update hidden forums minus this one 
  33. update_option( '_bbp_hidden_forums', array_unique( array_filter( array_values( $hidden ) ) ) ); 
  34.  
  35. // Only run queries if visibility is changing 
  36. if ( bbp_get_public_status_id() !== $current_visibility ) { 
  37.  
  38. // Update forums visibility setting 
  39. global $wpdb; 
  40. $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_public_status_id() ), array( 'ID' => $forum_id ) ); 
  41. wp_transition_post_status( bbp_get_public_status_id(), $current_visibility, get_post( $forum_id ) ); 
  42. bbp_clean_post_cache( $forum_id ); 
  43.  
  44. do_action( 'bbp_publicized_forum', $forum_id ); 
  45.  
  46. return $forum_id;