Skip to:
Content
Pages
Categories
Search
Top
Bottom

Network-wide forums on WP multisite + BP installation

Viewing 2 replies - 1 through 2 (of 2 total)

  • nsbp001
    Participant

    @nsbp001

    I am looking for a solution to have network-wide forums such that each site can access them at http://continuum.nsbp.org/sitename/forums and all these pages would pull the same data for these respective pages.

    I would like Groups forums where each site network-wide can participate in those forums, and I would like to have network-wide forums that are not associated with any groups.

    Is this possible? Can the bbPress plugin do this and have a page that can be in the menus as if it was a BP component?


    nsbp001
    Participant

    @nsbp001

    Perhaps this is the solution, found at https://gist.github.com/sc0ttkclark/e5de9d9f2f13964bcecc
    Code to enable having the main bbPress forums on a separate sub-site. Requires: WP Multisite, BuddyPress on main site and network-activated, bbPress on main site and sub-site

    <?php
    /**
    * Remove and add a custom function for bbPress’ BuddyPress activity filter
    */
    function custom_bbp_notifications_fix() {
    if ( !defined( ‘BBPRESS_FORUMS_BLOG_ID’ ) || !BBPRESS_FORUMS_BLOG_ID ) {
    return;
    }
    remove_filter( ‘bp_notifications_get_notifications_for_user’, ‘bbp_format_buddypress_notifications’, 10, 5 );
    add_filter( ‘bp_notifications_get_notifications_for_user’, ‘custom_bbp_format_buddypress_notifications’, 10, 5 );
    add_action( ‘bbp_template_before_user_topics_created’, ‘custom_bbp_switch_to_forums’ );
    add_action( ‘bbp_template_before_user_replies’, ‘custom_bbp_switch_to_forums’ );
    add_action( ‘bbp_template_before_user_favorites’, ‘custom_bbp_switch_to_forums’ );
    add_action( ‘bbp_template_before_user_subscriptions’, ‘custom_bbp_switch_to_forums’ );
    add_action( ‘bbp_template_after_user_topics_created’, ‘custom_bbp_switch_from_forums’ );
    add_action( ‘bbp_template_after_user_replies’, ‘custom_bbp_switch_from_forums’ );
    add_action( ‘bbp_template_after_user_favorites’, ‘custom_bbp_switch_from_forums’ );
    add_action( ‘bbp_template_after_user_subscriptions’, ‘custom_bbp_switch_from_forums’ );
    }
    add_action( ‘init’, ‘custom_bbp_notifications_fix’ );
    /**
    * Format the BuddyBar/Toolbar notifications
    *
    * @since bbPress (r5155)
    *
    * @package bbPress
    *
    * @param string $action The kind of notification being rendered
    * @param int $item_id The primary item id
    * @param int $secondary_item_id The secondary item id
    * @param int $total_items The total number of messaging-related notifications waiting for the user
    * @param string $format ‘string’ for BuddyBar-compatible notifications; ‘array’ for WP Toolbar
    */
    function custom_bbp_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = ‘string’ ) {
    if ( ‘bbp_new_reply’ == $action ) {
    custom_bbp_switch_to_forums();
    $action = bbp_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format );
    custom_bbp_switch_from_forums();
    }
    return $action;
    }
    /**
    * @var boolean $custom_bbp_switch
    */
    global $custom_bbp_switch;
    /**
    * Switch to forums blog, if it’s not the current blog
    */
    function custom_bbp_switch_to_forums() {
    global $custom_bbp_switch;
    $custom_bbp_switch = ( get_current_blog_id() != BBPRESS_FORUMS_BLOG_ID );
    if ( $custom_bbp_switch ) {
    // Switch to forum site
    switch_to_blog( BBPRESS_FORUMS_BLOG_ID );
    }
    }
    /**
    * Switch back to current blog, if not the forums blog
    */
    function custom_bbp_switch_from_forums() {
    global $custom_bbp_switch;
    if ( $custom_bbp_switch ) {
    restore_current_blog();
    }
    $custom_bbp_switch = false;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar