Custom Function For Hiding Group Menu On BP

Hello Team-

Member is looking for a custom function that allows him to hide the Buddypress group header based on specific group ID. So when the member that is assigned to that group, goes to the group page, the group header is hidden. Any Buddypress fanatics out there want to assist our member out?

Thanks,
Ken - WPMU DEV Support

  • Denitsa
    • WordPress Warrior

    Hello Christopher,
    I hope you're doing good!

    I've pinged our SLS (second level support) to provide the solution you're looking for. It may take them a little while to check this and provide a feedback, since those guys have a lot on their plate, so thanks for your patience in advance!

    Regards,
    Denitsa

  • Panos
    • SLS

    Hi Christopher,

    BP allows to override template files by copying them in your theme's directory. For hiding the header from the groups page, first copy file
    wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/groups/single/cover-image-header.php
    Then you will need to create folders with the following order in your theme's directory:
    -->wp-content
    ------->themes
    ------------>yourtheme
    ----------------->buddypress
    ---------------------->groups
    --------------------------->single

    Paste the file you copied previously in the "single" folder.

    Now, BP will use this file to display the header.

    You need to open this file and on the beginning add the following lines:

    if( is_user_logged_in() && groups_is_user_member( bp_loggedin_user_id(), bp_get_current_group_id() ) ){
    	return;
    }

    Please let me know if something wasn't clear.

    Thanks!

  • Panos
    • SLS

    Hi Christopher ,

    I probably understood wrong here :slight_smile:

    If you want to hid the header for every user visiting that specific group page, use code:

    if( bp_get_current_group_id() == 8 ){
    	return;
    }

    If you need to hide the header of that group only for members who are registered to that group use

    if( bp_get_current_group_id() == 8 && is_user_logged_in() && groups_is_user_member( bp_loggedin_user_id(), bp_get_current_group_id() ) ){
    	return;
    }

    Cheers!

  • Christopher
    • Design Lord, Child of Thor

    Hello,
    When I added

    if( bp_get_current_group_id() == 8 ){
    	return;
    }

    to cover-image-header.php, it didn't do anything, so then I added it to group-header.php and it successfully removed the images, but still not the navigation. See the attached image.

    I am looking to remove this entire box, only on group id 8. Where do I go from here?

    Thanks

  • Panos
    • SLS

    Hi Christopher ,

    Didn't notice you needed the menus gone too :slight_smile:

    Similar to previous reply copy file
    wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/groups/single/home.php

    and paste it to the
    -->wp-content
    ------->themes
    ------------>yourtheme
    ----------------->buddypress
    ---------------------->groups
    --------------------------->single

    The open it with a text editor and edit line 42 which should contain:

    <?php //bp_get_options_nav(); ?>

    and change it to:

    <?php
                    if( bp_get_current_group_id() == 8 ){
                         bp_get_options_nav();
                    }
                    ?>

    and save file.

    Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.