BuddyDev

Search

[Resolved] Hide a specific group on my profile tab

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

    Hi there, thanks for this forum I learned a lot of BuddyPress customizations.

    Is there a way to hide a specific group in my profile group tab?

    For example, if the group type is SECRET

    The groups under SECRET group type will hide in my profile group tab.

    I’m on this code but I don’t know what to do next…

    $group_args = array(
    ‘group_type’ => array( ‘secret’, ‘secret2’ ),
    );

    if ( bp_has_groups( $group_args ) && current_user_can(‘subscriber’) ) {

    }

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2952
    Ravi on #40581

    Hello Simon,

    Thank you for asking. Please try the following code:

    
    
    add_filter( 'bp_after_has_groups_parse_args', function ( $r ) {
    
    	// Not show secret groups to other users except user on his own profile.
    	if ( bp_is_user() && ! bp_is_my_profile() ) {
    		$r['group_type__not_in'] = array( 'secret' );
    	}
    
    	return $r;
    } );
    
    

    Regards
    Ravi

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

    Thanks for the response Ravi, unfortunately the code won’t work.

    As of now my current setting of this secret group is in privacy hidden with the group type of secret. Also I’m using the buddyboss pro plugin

    Is it possible to hide this secret group from the members, not for super admin and organizers? Sorry for asking too much =(

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2952
    Ravi on #40597

    Hello Simon,

    As you said the privacy of secret groups is hidden and hidden groups by default are invisible to non-members. These group names and descriptions are not listed in sitewide directories, and their contents are accessible only to members of the group. Because the group is unlisted, users cannot request membership. Instead, individuals can only join the group by invitation.

    what are the organizers you are referring to is it group administrator?.

    Please help me to understand your requirement so that I can help You.

    Regards
    Ravi

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

    Hi Ravi, sorry for the confusion.

    So here is my scenario.

    I have a group type called SECRET is there a way to hide the groups under the group type of secret? Even if the members are already joined the reason to hide these groups are solely for group messaging purposes only.

    Hoping this can help you understand the scenario.

    Thanks in advance

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2952
    Ravi on #40629

    Hello Simon,

    Thank you for the clarification. Can you provide me screenshots because it will give a more clear view of your requirements ?. As per my understanding, you are looking for a way to hide secret groups under Group’s directory > Secret Tab. Or point me you the link where these groups are rendering and you want to hide them.

    Regards
    Ravi

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

    Hi Ravi thanks for the reply please check the screenshot
    https://prnt.sc/1sxxstm

    Somehow, I want to hide the group under secret group type in my profile -> group tab.

    Thank you!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2952
    Ravi on #40646

    Hello Simon

    Thank you for sharing the screenshot. Try the following code:

    
    add_filter( 'bp_after_has_groups_parse_args', function ( $r ) {
    
    	// Not show secret groups.
    	if ( bp_is_user() && bp_is_current_action( 'my-groups' ) ) {
    		$r['group_type__not_in'] = array( 'secret' );
    	}
    
    	return $r;
    } );
    
    

    Regards
    Ravi

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

    Thanks Ravi, that worked! I will just hide the group counter because the count does not update.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2952
    Ravi on #40652

    Hello Simon,

    Thank you for the acknowledgment. BuddyPress handles the group’s counter in a different way which is why this issue is occurring.

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: resolved