Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm looking to have the default view for Groups be the Forum component instead of the Activity component. What's the best/easiest way to alter the default landing component/page?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

[Edit - My original answer will only work in the upcoming BP 1.6]

For the moment, you'll have to use something like the following, which is a modified version of bp_core_new_nav_default() (a function that is broken in the case of groups, because of various slug-related stuff):

function bbg_set_new_group_default_subnav() {
    global $bp;

    if ( bp_is_group() ) {
        // Set up your new default
        $new_screen_function = 'groups_screen_group_forum';
        $new_default_slug = 'forum';

        $parent_slug = bp_get_current_group_slug();

        if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) {
            if ( !is_object( $function[0] ) )
                remove_action( 'bp_screens', $function, 3 );
                    else
                remove_action( 'bp_screens', array( &$function[0], $function[1] ), 3 );
        }

        $bp->bp_nav[$parent_slug]['screen_function'] = &$new_screen_function;

        if ( bp_is_groups_component() && !bp_current_action() ) {
            if ( !is_object( $new_screen_function[0] ) ) {
                add_action( 'bp_screens', $new_screen_function );

            } else {
                add_action( 'bp_screens', array( &$new_screen_function[0], $new_screen_function[1] ) );
            }

            $bp->current_action = $new_default_slug;
       }
    }
}
add_action( 'bp_setup_nav', 'bbg_set_new_group_default_subnav', 999 );

function bbg_set_new_group_default_action() {
    global $bp;

    if ( bp_is_group() && !bp_current_action() ) {
        $bp->current_action = 'forum';
    }
}
add_action( 'bp_setup_globals', 'bbg_set_new_group_default_action', 999 );
share|improve this answer
    
Hmmm. What version of BP is that in? I don't seem to have it in 1.5.4. –  ZaMoose Mar 12 '12 at 14:57
    
Whoops. That's going to be in BP 1.6. –  Boone Gorges Mar 12 '12 at 15:19
    
This mostly works, though it seems to interfere with the old group Home/group Activity tab -- can't seem to reach it. –  ZaMoose Mar 12 '12 at 17:15
    
Edited again. This should work. –  Boone Gorges Mar 12 '12 at 19:19
    
Sweet! That works like a charm. –  ZaMoose Mar 12 '12 at 20:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.