bbp_repair_forum_visibility

Recaches the private and hidden forums.

Description

(array) bbp_repair_forum_visibility(); 

Returns (array)

An array of the status code and the message


Usage

  1. if ( !function_exists( 'bbp_repair_forum_visibility' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_repair_forum_visibility(); 
  7.  

Defined (1)

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

/includes/forums/functions.php  
  1. function bbp_repair_forum_visibility() { 
  2.  
  3. // First, delete everything. 
  4. delete_option( '_bbp_private_forums' ); 
  5. delete_option( '_bbp_hidden_forums' ); 
  6.  
  7. // Next, get all the private and hidden forums 
  8. $private_forums = new WP_Query( array( 
  9. 'suppress_filters' => true,  
  10. 'nopaging' => true,  
  11. 'post_type' => bbp_get_forum_post_type(),  
  12. 'post_status' => bbp_get_private_status_id(),  
  13. 'fields' => 'ids' 
  14. ) ); 
  15. $hidden_forums = new WP_Query( array( 
  16. 'suppress_filters' => true,  
  17. 'nopaging' => true,  
  18. 'post_type' => bbp_get_forum_post_type(),  
  19. 'post_status' => bbp_get_hidden_status_id(),  
  20. 'fields' => 'ids' 
  21. ) ); 
  22.  
  23. // Reset the $post global 
  24. wp_reset_postdata(); 
  25.  
  26. // Bail if queries returned errors 
  27. if ( is_wp_error( $private_forums ) || is_wp_error( $hidden_forums ) ) 
  28. return false; 
  29.  
  30. // Update the private/hidden options 
  31. update_option( '_bbp_private_forums', $private_forums->posts ); // Private forums 
  32. update_option( '_bbp_hidden_forums', $hidden_forums->posts ); // Hidden forums 
  33.  
  34. // Complete results 
  35. return true;