Change BuddyPress Groups Starting Tab

| July 30, 2012 | 3 Comments

OK So after a LOT of searching and looking through out dated posts I finally figured out how to make the BuddyPress groups main page default to the forums tab instead of the home tab which is confusing because commenting is enabled, even when I have it turned off.

Here is the code for BuddyPress 1.5 and I hope it helps. Note that this can be used in either your bp-custom.php file which HAS to be located in wp-content/plugins/ OR your themes functions.php file.

/* Redirect for group home tab */
function redirect_group_home() {
global $bp;
$path = clean_url( $_SERVER['REQUEST_URI'] );
$path = apply_filters( 'bp_uri', $path );
if (bp_is_group_home() && strpos( $path, $bp->bp_options_nav[$bp->groups->current_group->slug]['home']['slug'] ) === false ) {
if ($bp->groups->current_group->is_user_member || $bp->groups->current_group->status == 'public') {
bp_core_redirect( $path . 'forum/' );
}
}
}
function move_group_activity_tab() {
global $bp;
if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item) {
unset($bp->bp_options_nav[$bp->groups->current_group->slug]['home']);
}
}
//The following line redirects to a group forum page rather than a group activity page
add_action('bp_init', 'redirect_group_home' );
//The following line removes the group activity tab entirely
//add_action('bp_init', 'move_group_activity_tab');

Incoming search terms:

  • TOMMI WHITE brush

Category: BuddyPress

Comments (3)

Trackback URL | Comments RSS Feed

  1. Magnus Melin says:

    Try applying the “bp_groups_default_extension” filter and returning “forum”. That should be all.

  2. Nicolás Galarza says:

    Hi! great info. I’m trying to apply it but I’m not sure where I should insert the code.

    Should I do it in anywhere inside functions.php?

    I did this, is this ok? cause it didn’t work: http://screencast.com/t/Fs7bhXbCfIc

    thanks

    • Tommy White says:

      You could try the following in functions.php or bp-custom.php. The bp-custom.php file will need to be created and placed directly in the plugins folder if you want to use it.

      function remove_group_options()
      {
      global $bp;
      $parent_slug = isset( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ? $bp->groups->current_group->slug : $bp->groups->slug;
      bp_core_remove_nav_item( $parent_slug, 'eventos' );
      bp_core_remove_nav_item( $parent_slug, 'group-events' );
      }
      add_action( 'bp_setup_nav', 'remove_group_options' );

Leave a Reply

Your email address will not be published. Required fields are marked *