Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How To Limit/Hide The "Friends" Tab Only To Account Owner & Admin?

  • Avatar of rizingsun
    rizingsun
    Participant

    @rizingsun

    Greetings folks.

    I would like to limit access to the “Friends” tab on a user’s page to the account owner and the admin?

    Plus how can I hide the friends tab (in the same way “Messages” and “Settings” are only viewable for an account owner)?

    Any idea how to do that?

    For example, when you click on a BP user’s page, you see the “Activity”, “Profile”, “Friends, “Groups” tabs.

    How can I remove the “Friends” tab from that area, and only allow access to the account owner (like “Messages” and “Settings”?

    This is basically a privacy issue that I’m worried about.

    Any help would be appreciated.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Avatar of bp-help
    bp-help
    Participant

    @bphelp

    You can use this tutorial http://wpmu.org/how-to-add-profile-privacy-to-buddypress/
    its meant for profiles but it can be adapted for friends. Follow it exactly but instead of putting

    3. Edit your theme file to include the friendship check:
    To restrict profile info, open up /members/single/profile.php and add this at the top of the page:

    add that code in 3. instead to /members/single/friends.php

    You may also want to change the test in 2. step to:
    You must be friends in order to access users friends.

    Avatar of rizingsun
    rizingsun
    Participant

    @rizingsun

    Thanks @bphelp !

    I’m trying to make it so that a user’s “Friends” tab is only visible to that specific user (like “Settings” and “Messages”).

    I think your advice would still enable a user’s friends to see their other friends.

    Is there any way to make it so that the a user’s “Friends” tab is only visible to said user?

    Avatar of bp-help
    bp-help
    Participant

    @bphelp

    I already tested the advice I gave you and if you click on a users friends tab that you are not friends with it displays the message “You must be friends in order to access users friends.”
    I am sure there is someway to build upon that function so it only displays the friends tab if you are friends with that user.

    Avatar of rizingsun
    rizingsun
    Participant

    @rizingsun

    Thanks @bphelp

    But my intent is that the “Friends” tab should not be visible to anyone except the account user (like “Settings” and “Messages” tabs are only visible to an account user).

    Even if you’re friends with a user, you should not be able to see his other friends.

    Complete privacy.

    I would like to make the “Friends” tab a private setting. Is there any way to do that?

    Avatar of Brajesh Singh
    Brajesh Singh
    Participant

    @sbrajesh

    You Can put this code in your bp-custom.php and It will take care of your issue

    `
    add_action(‘bp_friends_setup_nav’,’bpdev_custom_hide_friends_if_not_self’);

    function bpdev_custom_hide_friends_if_not_self(){
    if(bp_is_my_profile()|| is_super_admin())
    return ;

    bp_core_remove_nav_item(‘friends’);

    }

    `

    hope that helps.

    Avatar of rizingsun
    rizingsun
    Participant

    @rizingsun

    Wow @sbrajesh !

    That seems to work! Thank you very much!

    Avatar of Brajesh Singh
    Brajesh Singh
    Participant

    @sbrajesh

    No problem. You are most welcome :)

    Avatar of bp-help
    bp-help
    Participant

    @bphelp

    Great job @sbrajesh !

    Avatar of Ishanna
    Ishanna
    Participant

    @ishanna

    Hallo @sbrajesh !

    I tried use code:

    
    add_action(‘bp_friends_setup_nav’,'bpdev_custom_hide_friends_if_not_self’);
    
    function bpdev_custom_hide_friends_if_not_self(){
    if(bp_is_my_profile()|| is_super_admin())
    return ;
    
    bp_core_remove_nav_item(‘friends’);
    
    }
    
    

    I copied and pasted the code into the ‘bp_custom.php’ file but it did not work for me.
    I’m new to wordpress, html, php and css but I seem to find my way til now. Some advise please? I really need this option to work and I can’t find a plugin that cover this.

    Kind regards,

    Avatar of aces
    aces
    Participant

    @aces

    @ishanna

    Could your problem be a copy/paste error?

    You appear to be using and – they should all be '

    Avatar of Ishanna
    Ishanna
    Participant

    @ishanna

    @aces

    Yes! Thank you, it works. :D

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

You must be logged in to reply to this topic.