Skip to:
Content
Pages
Categories
Search
Top
Bottom

Remove the Activity Tab from the buddypress profile page

  • Avatar of silonimekuri
    silonimekuri
    Participant

    @silonimekuri

    Hi All,
    This is my first post in this forum. I am working on a buddypress site (V 1.6.1). The requirement is to have only the message, friends and settings tab in the member profile page.
    I figured out that if we want to remove the activity tab, we can do so by commenting out

    parent::setup_nav( $main_nav, $sub_nav ); in the function setup_nav()

    in buddypress/bp-activity/bp-activity-loader.php

    I know that its not a very good idea to change the core files. But I dont know how to achieve this in bp-custom.php.
    Is there a way to achieve this in the bp-custom.php file or override the core buddypress functionality somehow?

    Any pointers in this regard would be of great help.

    Thanks in advance.

    Regards,
    Siloni

Viewing 19 replies - 1 through 19 (of 19 total)
  • Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    function bp_remove_nav_tabs() {

    bp_core_remove_nav_item( ‘activity’ );

    }
    add_action( ‘bp_setup_nav’, ‘bp_remove_nav_tabs’, 15 );

    Avatar of silonimekuri
    silonimekuri
    Participant

    @silonimekuri

    Thanks for your reply modemlooper. I copy pasted your code in bp-custom.php
    But I am getting the below error:

    Fatal error: Cannot access empty property in
    Site\wordpress\wordpress\wp-content\plugins\buddypress\bp-core\bp-core-template.php on line 823

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    function bp_remove_nav_tabs() {
    global $bp;
    bp_core_remove_nav_item( ‘activity’ );

    }
    add_action( ‘bp_setup_nav’, ‘bp_remove_nav_tabs’, 15 );

    Avatar of silonimekuri
    silonimekuri
    Participant

    @silonimekuri

    Now I am getting the error:

    Page Not Found
    We’re sorry, but we can’t find the page that you’re looking for. Perhaps searching will help.

    Is the parent_id passed to bp_core_remove_nav_item correct?

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    That’s the code to remove tabs. Make sure it it tyled corectly. Cutting and pasting is not good. Type it out.

    Avatar of silonimekuri
    silonimekuri
    Participant

    @silonimekuri

    I typed the code but still its not working. Thanks anyways for your time.

    Regards,
    Siloni

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    add this into function:

    define( ‘BP_DEFAULT_COMPONENT’, ‘profile’ );

    Avatar of silonimekuri
    silonimekuri
    Participant

    @silonimekuri

    It’s still not working. I see that if I remove the following lines of code from bp-core-template.php (function bp_is_current_component), then I dont get any error and the activity tab is also removed from the nav bar.

    } elseif ( isset( $bp->{$component}->root_slug ) && $bp->{$component}->root_slug == $bp->current_component ) {
    $is_current_component = true;

    // Because slugs can differ from root_slugs, we should check them too
    } elseif ( isset( $bp->{$component}->slug ) && $bp->{$component}->slug == $bp->current_component ) {
    $is_current_component = true;

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Edit core code at your own peril. The code I suggest works. It’s used in many sites and it is in a plugin I crested that has been downloaded more than 50,000 times. If you have been editing core code I think you should revert your install back to a fresh one. If you run into problems no one here will be able to help you fix it if core code has been changed.

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Try:
    bp_core_remove_nav_item( $bp->activity->slug );

    Avatar of silonimekuri
    silonimekuri
    Participant

    @silonimekuri

    Hi,
    You are right. Even I dont want to edit the core code. I will install a fresh version of buddypress and see if that works. I will update this thread with the results.

    Thanks again Modemlooper for your valuable feedback and time.

    Regards,
    Siloni

    Avatar of silonimekuri
    silonimekuri
    Participant

    @silonimekuri

    Hi Modemlooper,
    I am installed both wordpress and buddypress again today. But I am still getting the same error.
    I have added the following to my bp-custom.php. The default highlighted tab is the friends tab after adding define( ‘BP_DEFAULT_COMPONENT’, ‘friends’ );.

    activity->slug );

    }
    add_action( ‘bp_setup_nav’, ‘bp_remove_nav_tabs’, 15 );

    ?>

    Regards,
    Siloni

    Avatar of silonimekuri
    silonimekuri
    Participant

    @silonimekuri

    The code got truncated in my earlier post. I have added the following in the bp-custom.php. This is inside the php tags.

    define( ‘BP_DEFAULT_COMPONENT’, ‘friends’ );

    function bp_remove_nav_tabs() {
    global $bp;

    bp_core_remove_nav_item( $bp->activity->slug );

    }
    add_action( ‘bp_setup_nav’, ‘bp_remove_nav_tabs’, 15 );

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    I don’t know why it’s not working for you. Try this:

     
    function bp_remove_nav_tabs() {
    global $bp;
    $bp->bp_nav['activity'] = false;
    }
    add_action( ‘bp_init’, ‘bp_remove_nav_tabs’, 999 );

    Avatar of Hope
    Hope
    Participant

    @amalsh

    Hi,

    Thanks for the solution @modemlooper, I want to hide profile activity tab from non-friends, how can i do this?

    Thanks
    Hope

    Avatar of bp-help
    bp-help
    Participant

    @bphelp

    So I guess no one figured this out yet? It needs a check if the user is logged in and if they are a friend to display the activity tab in the members profile. It also needs a check to see if it is the current user. If the current user is logged in and they see a member that they are not friends with in the members section then when they click on the members name then the activity tab should be omitted. Anyone got any thoughts on this or is this something we have to figure out on our own?

    Avatar of bp-help
    bp-help
    Participant

    @bphelp

    @modemlooper your code works to a degree:
    `function bp_remove_nav_tabs() {
    global $bp;
    bp_core_remove_nav_item( ‘activity’ );

    }
    add_action( ‘bp_setup_nav’, ‘bp_remove_nav_tabs’, 15 );`

    It gets rid of the activity tab including people you are friends with which is not good, and if you click on your own name in the members list then it fires of the error:
    Fatal error: Cannot access empty property in C:\xampp\htdocs\mysite\wp-content\plugins\buddypress\bp-core\bp-core-template.php on line 823. so whats the problem?

    Avatar of bp-help
    bp-help
    Participant

    @bphelp

    @modemlooper I wrote this function and it works without errors but it doesn’t show the profile activity tab if your friends with that user so I am thinking a friend check needs to be placed so it will show it if your friends. Anyway check out the code and see what you think should be done:
    `
    function hide_non_friend_profile_activity_tab(){
    if(bp_is_my_profile()|| is_super_admin())
    return ;

    bp_core_remove_nav_item(‘activity’);

    }
    add_action(‘bp_friends_setup_nav’,’hide_non_friend_profile_activity_tab’);
    `

    Avatar of NK-cell
    NK-cell
    Participant

    @nk-cell

    hey @modemlooper you code worked for with define function. So,

    // removing profile activiy
    define( ‘BP_DEFAULT_COMPONENT’, ‘profile’ );

    function bp_remove_nav_tabs() {
    global $bp;
    bp_core_remove_nav_item( ‘activity’ );
    }
    add_action( ‘bp_setup_nav’, ‘bp_remove_nav_tabs’, 15 );

    Thank you so much for your efforts…Take care man!

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

The topic ‘Remove the Activity Tab from the buddypress profile page’ is closed to new replies.