Skip to:
Content
Pages
Categories
Search
Top
Bottom

Remove the Activity Tab from the buddypress profile page


  • Ynasr
    Participant

    @ynasr

    Hi,

    I am trying to remove the “Activity” tab from the navigation bar on the member profile page. I have been searching for a solution for days. While pasting the following code in child theme functions.php seems to work for other users, when I do so i am getting the following error:

    Code i used:

    function bphelp_remove_groups_from_profile(){
    bp_core_remove_nav_item(‘activity’);
    }
    add_action(‘bp_activity_setup_nav’,’bphelp_remove_groups_from_profile’);

    Error message:

    ” This is somewhat embarrassing, isn’t it?
    It seems we can’t find what you’re looking for. Perhaps searching can help.”

    FYI – i have also tried pasting this into my bp-custom.php but its giving me the same error. Could anyone help me out with this please ?

    Many thanks,
    Yvan

Viewing 4 replies - 1 through 4 (of 4 total)

  • scoobs2000
    Participant

    @scoobs2000

    Hi below is the code I use, placed in the child theme functions.php
    its does little bit more than your OP, however you can see where I have removed the activity tab for low level members (paid membership site) –

    function bbg_change_profile_tab_order() {
        global $bp;
    
        $bp->bp_nav['profile']['position'] = 1;
        $bp->bp_nav['activity']['position'] = 20;
        $bp->bp_nav['messages']['position'] = 30;
        $bp->bp_nav['notifications']['position'] = 40;
        $bp->bp_nav['friends']['position'] = 50;
        $bp->bp_nav['groups']['position'] = 60;
        $bp->bp_nav['forums']['position'] = 70;
        $bp->bp_nav['media']['position'] = 80;
        $bp->bp_nav['orders']['position'] = 90;
        $bp->bp_nav['settings']['position'] = 100;
    
        if (current_user_is('s2member_level0')) {
            $bp->bp_nav['forums'] = false;
            bp_core_remove_nav_item($bp->friends->id);
            bp_core_remove_nav_item($bp->activity->id);
            bp_core_remove_nav_item($bp->groups->id);
            bp_core_remove_nav_item($bp->messages->id);
        }
    
    }
    add_action( 'bp_setup_nav', 'bbg_change_profile_tab_order', 999 );

    If i recall correctly when putting this together I required the function to run last after all other plugins – as in my case many plugins where executing scripts at odd priorities and overriding the above function, so I just push the function to 999 and it appears to work all fine.

    in your case you could try:

    function bp_remove_profile_tab_activity(){
       global $bp;
       bp_core_remove_nav_item($bp->activity->id);
    }
    add_action( 'bp_setup_nav', 'bp_remove_profile_tab_activity', 999 );

    but I’m a bit of a ruff coder and the above is still in a development project – so there may be better ways to do this. anyone?


    ckchaudhary
    Participant

    @ckchaudhary

    You are getting a 404 error.
    Coz, you’ve removed the default component of profile( activity ) and have not specified another default component. So buddypress doesn’t know what to display on a single members page( e.g: domain.com/members/john/ ). If you set default component to something other than activity they it works fine.
    Working code:-

    if( !defined( 'BP_DEFAULT_COMPONENT' ) ){
        define( 'BP_DEFAULT_COMPONENT', 'profile' );
    }
    function bp_remove_profile_tab_activity(){
       bp_core_remove_nav_item( buddypress()->activity->id );
    }
    add_action( 'bp_setup_nav', 'bp_remove_profile_tab_activity', 999 );

    Ynasr
    Participant

    @ynasr

    Thanks a lot ckchaudhary! This got rid of the activity tab. That said, i forgot to mentioned i only wanted to remove the activity tab for other users. So basically if a user is logged in they should have the option to click on their activity tab.

    Does that make sense? If so, how would I achieve that? Apologies for all the queries and thanks so much for your support.

    Best,
    Yvan


    Ynasr
    Participant

    @ynasr

    Thanks a lot ckchaudhary! nvm – I think i figured this out

    Thanks a lot!
    Yvan

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove the Activity Tab from the buddypress profile page’ is closed to new replies.
Skip to toolbar