BuddyDev

Search

[Resolved] Hide Members List in Groups

Tagged: 

  • Participant
    Level: Initiated
    Posts: 12
    simon on #40599

    Hi Ravi, I’m looking to hide the group’s member tab in a specific group. Thank you.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2936
    Ravi on #40630

    Hello Simon,

    Thank you for telling me. Please use the following code it will hide the members tab except for super admin or group admin.

    
    add_action( 'groups_setup_nav', function () {
    
    	if ( is_super_admin() || groups_is_user_admin( get_current_user_id(), bp_get_current_group_id() ) ) {
    		return;
    	}
    
    	// If will hide members tab for all users. You can place conditions whom to show or hide this group.
    	bp_core_remove_subnav_item( bp_get_current_group_slug(), 'members', 'groups' );
    } );
    
    

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 12
    simon on #40633

    Hi Ravi thanks for the reply.

    • This reply was modified 2 years, 7 months ago by simon. Reason: wrong thread
  • Participant
    Level: Initiated
    Posts: 12
    simon on #40648

    Hi Ravi, question again I was wondering how to hide the members tab per name of the group…

    I’m trying on this code but it does not work on my end.

    add_action( ‘groups_setup_nav’, function () {

    $specialgroup = array(“Test Group”,”Test Group 1″); //or group IDs or group names

    if ( bp_get_group_name($specialgroup)) {
    return;
    }

    bp_core_remove_subnav_item( bp_get_current_group_slug(), ‘members’, ‘groups’ );
    } );

    Wondering if you can enlighten or help me with code above? Thank you very much again!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2936
    Ravi on #40653

    Hello Simon,

    Try the following code:

    
    add_action( 'groups_setup_nav', function () {
    
    	if ( is_super_admin() || groups_is_user_admin( get_current_user_id(), bp_get_current_group_id() ) ) {
    		return;
    	}
    
    	$excluded_names = array( 'Test Group', 'Test Group 1' );
    
    	if ( in_array( bp_get_current_group_name(), $excluded_names ) ) {
    		// If will hide members tab for all users. You can place conditions whom to show or hide this group.
    		bp_core_remove_subnav_item( bp_get_current_group_slug(), 'members', 'groups' );
    	}
    } );
    
    

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 12
    simon on #40658

    Thank you very much Ravi the code above works =)

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2936
    Ravi on #40660

    Hello Simon,

    Thank you for the acknowledgment. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] Hide Members List in Groups’ is closed to new replies.

This topic is: resolved