BuddyDev

Search

[Resolved] Hide Members List in Groups

Tagged: 


  • Participant
    Level: Initiated
    Posts: 5
    James Moss on #35440

    Hi Brajesh,

    Just following an earlier thread (https://buddydev.com/support/forums/topic/hide-members-directory-in-groups/), I don’t want to hide the members tab – I would only like to hide the Members in the list. So that only the group admin and moderators are visible. Would it be possible?

    Would really appreciate if you could kindly help.

    Kind regards,
    James


  • Keymaster
    (BuddyDev Team)
    Posts: 17485
    Brajesh Singh on #35453

    Hi James,
    Thank you for the question.

    I am asking one of my colleagues to look into it and assist you with the code.

    Regards
    Brajesh


  • Participant
    Level: Initiated
    Posts: 5
    James Moss on #35458

    Thanks Brajesh, really appreciate.

    Kind regards,
    James


  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1258
    Ravi on #35467

    Hello James,

    Please try the following code. It will list only group admin and moderators under members tab.

    
    
    /**
     * List only group admins and moderators only under members tab
     *
     * @param array $r Parameters for group members.
     *
     * @return mixed
     */
    function buddydev_list_group_admins_moderators_only( $r ) {
    
    	$r['exclude_admins_mods'] = 0;
    	$r['group_role']          = array( 'admin', 'mod' );
    
    	return $r;
    }
    add_filter( 'bp_after_group_has_members_parse_args', 'buddydev_list_group_admins_moderators_only' );
    
    

    Regards
    Ravi


  • Participant
    Level: Initiated
    Posts: 5
    James Moss on #35470

    Hi Ravi,

    Thank you so much, it lists only the group admin under the members tab – which is great. But it hides the members from Group Admin and the Site Administrator as well.

    We wanted the Group Admin and Site Administrator to be able to see the Members in the Group. So all members should be hidden from each other (except from Group Admin and Site Admin).

    Best regards,
    James


  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1258
    Ravi on #35471

    Hello James,

    Please remove above mentioned code and use the following code

    
    /**
     * List only group admins and moderators only under members tab
     *
     * @param array $r Parameters for group members.
     *
     * @return mixed
     */
    function buddydev_list_group_admins_moderators_only( $r ) {
    
    	if ( is_super_admin() || groups_is_user_admin( bp_loggedin_user_id(), bp_get_current_group_id() ) ) {
    		return $r;
    	}
    
    	$r['exclude_admins_mods'] = 0;
    	$r['group_role']          = array( 'admin', 'mod' );
    
    	return $r;
    }
    add_filter( 'bp_after_group_has_members_parse_args', 'buddydev_list_group_admins_moderators_only' );
    
    

    Regards
    Ravi


  • Participant
    Level: Initiated
    Posts: 5
    James Moss on #35472

    Hi Ravi,

    Many thanks, worked perfectly.

    All the team at BuddyDev are just amazing, extremely helpful.

    Best regards,
    James


  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1258
    Ravi on #35473

    Hello James,

    Thank you for the kind words. I am glad that I could help.

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: resolved
Subscribe