BuddyDev

Search

[Resolved] Hide Members directory in Groups


  • Participant
    Level: Enlightened
    Posts: 26
    Vivek Mathur on #22191

    Hi Brajesh, I used your snippet for hiding Members directory except for admin users, which i found on one of the forums. Is there any similar snippet to hide the members directory in the groups also, or can it be set individually for groups?

    thanks,
    Vivek


  • Keymaster
    (BuddyDev Team)
    Posts: 10970
    Brajesh Singh on #22203

    Hi Vivek,
    Thank you for the question. We can certainly do that.

    Question:- What will happen when a user clicks on “members” tab in group? should we remove the member tab completely there or hide the entries?

    Doing it per group will need me to add settings. For now, Let us keep it simple and we can add settings later.

    Regards
    Brajesh


  • Participant
    Level: Enlightened
    Posts: 26
    Vivek Mathur on #22221

    Thanks, Brajesh. I suppose it would be better to hide the members tab.

    I understand having a group-wise setting would be more complex, so would it be possible to allow group directory visibility only to group admins and moderators?

    thanks,
    Vivek


  • Keymaster
    (BuddyDev Team)
    Posts: 10970
    Brajesh Singh on #22225

    Hi Vivek,
    Thank you.

    Please use this snippet in your bp-custom.php

    
    /**
     * Hide Group members for everyone except Site Admin, Group admin and group mods.
     */
    function buddydev_custom_disable_group_members() {
    
    	if ( ! bp_is_group() ) {
    		return;
    	}
    	$group_id = bp_get_current_group_id();
    	$user_id  = get_current_user_id();
    
    	if ( is_super_admin() || groups_is_user_admin( $user_id, $group_id ) || groups_is_user_mod( $user_id, $group_id ) ) {
    		return;
    	}
    
    	bp_core_remove_subnav_item( groups_get_current_group()->slug, 'members' );
    }
    
    add_action( 'groups_setup_nav', 'buddydev_custom_disable_group_members' );
    
    

    Regards
    Brajesh


  • Participant
    Level: Enlightened
    Posts: 26
    Vivek Mathur on #22294

    Thanks very much, Brajesh. Worked perfectly!


  • Keymaster
    (BuddyDev Team)
    Posts: 10970
    Brajesh Singh on #22300

    You are most welcome 🙂

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

This topic is: resolved
Subscribe