$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>forum - What's the easiest way to change the default landing page for BuddyPress groups?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

forum - What's the easiest way to change the default landing page for BuddyPress groups?

matteradmin9PV0评论

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?

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 edited Nov 18, 2015 at 16:17 user9447 1,7927 gold badges30 silver badges55 bronze badges asked Mar 8, 2012 at 5:02 ZaMooseZaMoose 1,6701 gold badge15 silver badges20 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 4

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

Versions of BuddyPress from 1.6 onwards

function bbg_change_group_default_extension( $default ) {
    return 'forum';
}
add_filter( 'bp_groups_default_extension', 'bbg_change_group_default_extension' );

Versions of BuddyPress prior to 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 );
Post a comment

comment list (0)

  1. No comments so far