BuddyDev

Search

[Resolved] Hide header on Settings, Visits, Activity and Notifications pages

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #46450

    Hi there, I’m using this CSS solution below, to hide the header on pages like Settings, Visits, Activity and Notifications, but I would prefer to change the mark-up instead.

    Could you please help me with a function to hide the header on these pages?

    Thank you.

    Regards
    Carsten

    .my-account #item-header {
    	display:none !important;
    }
    .my-profile #item-header {
    	display:block !important;	 
    }
  • Participant
    Level: Yogi
    Posts: 1105
    calu on #46452

    *Message page as well

  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #46462

    Hi Carsten,

    If you want to use php code for removing, you will need to override buddypress/members/single/home.php as there is no hook to disallow loading (while using default BuddyPress template packs).

    If you are comfortable with it, Please let me know which template pack are you using(I believe you were using legacy earlier) and I will share the snippet.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #46469

    Hi Brajesh, thanks for your help, I’m fine with overriding the home.php, I just add the new snippet, to my child theme, not copy all the content of the home.ph, to my knowledge?

    You remember right, I used Legacy before, but switched to Nouveau some years ago.

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #46470

    Hi Carsten,
    Thank you. If you are using Nouveau, then there are 2 way to do it.

    1. Using hooks( to use output buffer an discard but it is not reliable for future changes)
    2. Editing template file, we are going to use it.

    Please copy wp-content/plugins/buddypress/bp-templates/bp-nouveau/buddypress/members/single/home.php to your-child-theme/buddypress/members/single/home.php

    Now, Please look for these lines at the top

    
        <div id="item-header" role="complementary" data-bp-item-id="<?php echo esc_attr( bp_displayed_user_id() ); ?>" data-bp-item-component="members" class="users-header single-headers">
    
    		<?php bp_nouveau_member_header_template_part(); ?>
    
        </div><!-- #item-header -->
    
    

    and change it to

    
    <?php if ( ! in_array( bp_current_component(), array( 'activity', 'notifications', 'messages', 'settings' ) ) ) : ?>
        <div id="item-header" role="complementary" data-bp-item-id="<?php echo esc_attr( bp_displayed_user_id() ); ?>" data-bp-item-component="members" class="users-header single-headers">
    
    		<?php bp_nouveau_member_header_template_part(); ?>
    
        </div><!-- #item-header -->
    <?php endif; ?>
    
    

    Please feel free to update the slug list with any component you want to hide.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #46471

    Hi Brajesh, it’s working perfectly, except for ‘edit’ component,

    and for components with hyphens, ‘change-avatar’, ‘change-cover-image’. Is this because they are not part of Main Navs?

    In general, how do I add components with hyphens to a slug in an array like this one below, without getting a syntax error?

    Regards
    Carsten

      bp_core_new_nav_item( array( 
                'name' => 'Cover Image', 
                'slug' => 'change-cover-image', 
                'screen_function' => false, 
                'position' => 10,
                'parent_url'      => bp_loggedin_user_domain() . 'profile/edit/',
                'parent_slug'     => $bp->profile->slug,
                'default_subnav_slug' => 'change-cover-image',
                'show_for_displayed_user' => false,
          ) );
    }
  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #46493

    Hi Carsten.
    The component is the slug that is being used after the user name. e.g ‘profile’, ‘groups’, ‘friends’ etc.

    Have you added change cover image as top level?

    You can put any slugs in this array in the above code

    
    array( 'activity', 'notifications', 'messages', 'settings' )
    

    as

    
    array( 'activity', 'notifications', 'messages', 'settings', 'some-slug-with-dashes-and-string', 'some-other-slug' )
    

    and so on.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #46497

    Hi Brajesh, sorry for the misunderstanding, adding activity’, ‘notifications’, ‘messages’, ‘settings’ to your code, works perfectly well.

    1.

    I’m trying to add ‘edit’ to top level nav tabs as well, using this code, and it displays as it should.

    
    
     function profile_tab_yourtabname() {
          global $bp;
          
          bp_core_new_nav_item( array( 
                'name' => 'Rediger', 
                'slug' => 'profile/edit', 
                'screen_function' => false, 
                'position' => 10,
                'parent_url'      => bp_loggedin_user_domain() . 'profile/edit/',
                'parent_slug'     => $bp->profile->slug,
                'default_subnav_slug' => 'edit',
                'show_for_displayed_user' => false, //vises kun på egen profil, https://wordpress.org/support/topic/create-new-buddypress-profile-tab-code-snippet/#post-15999044
          ) );
    }
    
    add_action( 'bp_setup_nav', 'profile_tab_yourtabname' );
    
    

    But adding ‘edit’ to the array in your code does not hide the header for that component, which is weird.

    2. Have you added change cover image as top level?

    Yes, but I’m not sure how to add them with correct syntax? Components with hyphens, ‘change-avatar’ and ‘change-cover-image’ does not display. I have tried any combination using slashes as well, change/avatar, and change/cover/image, but without luck.

    function profile_tab_yourtabname() {
    global $bp;

    bp_core_new_nav_item( array(
    ‘name’ => ‘Coverbillede’,
    ‘slug’ => ‘profile/change-cove-/image’,
    ‘screen_function’ => false,
    ‘position’ => 10,
    ‘parent_url’ => bp_loggedin_user_domain() . ‘profile/change-cover-image’,
    ‘parent_slug’ => $bp->profile->slug,
    ‘default_subnav_slug’ => ‘change-cover-image’,
    ‘show_for_displayed_user’ => false,
    ) );
    }

    add_action( ‘bp_setup_nav’, ‘profile_tab_yourtabname’ );

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #46502

    Hi Carsten,
    In BuddyPress, only the part after the username is called component. The part that comes after component is called action.

    In your examples, ‘edit’, ‘change-cover-image’ etc are actions not component. ‘profile’ is the component in this case. so, you will need to exclude ‘profile’ is using the above code.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #46509

    Hi Brajesh, thank you for the clarification, this was a very useful information, and new to me, and probably helpful to others too.

    Regards
    Carsten

The topic ‘ [Resolved] Hide header on Settings, Visits, Activity and Notifications pages’ is closed to new replies.

This topic is: resolved