bp_nouveau_get_groups_directory_nav_items()

Get group directory navigation menu items.

Description

Source

File: bp-templates/bp-nouveau/includes/groups/functions.php

566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
function bp_nouveau_get_groups_directory_nav_items() {
    $nav_items = array();
 
    $nav_items['all'] = array(
        'component' => 'groups',
        'slug'      => 'all', // slug is used because BP_Core_Nav requires it, but it's the scope
        'li_class'  => array( 'selected' ),
        'link'      => bp_get_groups_directory_permalink(),
        'text'      => __( 'All Groups', 'buddyboss' ),
        'count'     => bp_get_total_group_count(),
        'position'  => 5,
    );
 
    if ( is_user_logged_in() ) {
 
        $my_groups_count = bp_get_total_group_count_for_user( bp_loggedin_user_id() );
 
        // If the user has groups create a nav item
        if ( $my_groups_count ) {
            $nav_items['personal'] = array(
                'component' => 'groups',
                'slug'      => 'personal', // slug is used because BP_Core_Nav requires it, but it's the scope
                'li_class'  => array(),
                'link'      => bp_loggedin_user_domain() . bp_get_groups_slug() . '/my-groups/',
                'text'      => __( 'My Groups', 'buddyboss' ),
                'count'     => $my_groups_count,
                'position'  => 15,
            );
        }
 
        // If the user can create groups, add the create nav
        if ( bp_user_can_create_groups() ) {
            $nav_items['create'] = array(
                'component' => 'groups',
                'slug'      => 'create', // slug is used because BP_Core_Nav requires it, but it's the scope
                'li_class'  => array( 'no-ajax', 'group-create', 'create-button' ),
                'link'      => trailingslashit( bp_get_groups_directory_permalink() . 'create' ),
                'text'      => __( 'Create a Group', 'buddyboss' ),
                'count'     => false,
                'position'  => 999,
            );
        }
    }
 
    // Check for the deprecated hook :
    $extra_nav_items = bp_nouveau_parse_hooked_dir_nav( 'bp_groups_directory_group_filter', 'groups', 20 );
 
    if ( ! empty( $extra_nav_items ) ) {
        $nav_items = array_merge( $nav_items, $extra_nav_items );
    }
 
    /**
     * Use this filter to introduce your custom nav items for the groups directory.
     *
     * @since BuddyPress 3.0.0
     *
     * @param  array $nav_items The list of the groups directory nav items.
     */
    return apply_filters( 'bp_nouveau_get_groups_directory_nav_items', $nav_items );
}

Changelog

Changelog
Version Description
BuddyPress 3.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.