Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/10/2013 07:17:14 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Introduce bbp_repair_forum_visibility() and use it:

  • when creating a new BuddyPress Group Forum
  • in the bbp_admin_repair_forum_visibility() tool

Fixes issues with new group forums not bumping the private/hidden forum ID's. Props r-a-y. Fixes #2349.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/forums/functions.php

    r5010 r5017  
    910910}
    911911
     912/**
     913 * Recaches the private and hidden forums
     914 *
     915 * @since bbPress (r5017)
     916 *
     917 * @uses delete_option() to delete private and hidden forum pointers
     918 * @uses WP_Query() To query post IDs
     919 * @uses is_wp_error() To return if error occurred
     920 * @uses update_option() To update the private and hidden post ID pointers
     921 * @return array An array of the status code and the message
     922 */
     923function bbp_repair_forum_visibility() {
     924
     925    // First, delete everything.
     926    delete_option( '_bbp_private_forums' );
     927    delete_option( '_bbp_hidden_forums'  );
     928
     929    // Next, get all the private and hidden forums
     930    $private_forums = new WP_Query( array(
     931        'suppress_filters' => true,
     932        'nopaging'         => true,
     933        'post_type'        => bbp_get_forum_post_type(),
     934        'post_status'      => bbp_get_private_status_id(),
     935        'fields'           => 'ids'
     936    ) );
     937    $hidden_forums = new WP_Query( array(
     938        'suppress_filters' => true,
     939        'nopaging'         => true,
     940        'post_type'        => bbp_get_forum_post_type(),
     941        'post_status'      => bbp_get_hidden_status_id(),
     942        'fields'           => 'ids'
     943    ) );
     944
     945    // Reset the $post global
     946    wp_reset_postdata();
     947
     948    // Bail if queries returned errors
     949    if ( is_wp_error( $private_forums ) || is_wp_error( $hidden_forums ) )
     950        return false;
     951
     952    // Update the private/hidden options
     953    update_option( '_bbp_private_forums', $private_forums->posts ); // Private forums
     954    update_option( '_bbp_hidden_forums',  $hidden_forums->posts  ); // Hidden forums
     955
     956    // Complete results
     957    return true;
     958}
     959
    912960/** Count Bumpers *************************************************************/
    913961
Note: See TracChangeset for help on using the changeset viewer.