buddypress friend privacy

Is this code from Ritchie_KS in a previous topic still good? I want to make sure users can only have their acitivy seen by there friends.If so, what file does it go in, where do I put it, do I need to remove anything and what happens if there is an upgrade?
Thanks!!!!!
SEE BELOW:

WPMU DEV - The WordPress Experts » BuddyPressAdditional BuddyPress Profile Privacy SettingsSubscribe by FeedAdd this topic to your favorites (?)Subscribe to This TopicnycwebworksMember

Started in 16th June 2011 (1 month ago) #
By default, it appears that BuddyPress profile settings have only 2 possible privacy settings--visible to everyone or visible only to logged in members. Is there a hack/plugin that will allow member to make their profiles visible only to BuddyPress "friends"?
Ideally, users should be able to set this privacy option individually (e.g., each member could choose their own setting). However, I'd settle for a hack that changes the behavior of the "only visible to logged in members" setting to "only visible to friends". Any suggestions?
Help & Support from WPMU DEV members and staff
Richie_KSGeeky Developer
Reputation:1,413

Say thanks! Give this user points
1000 points = free life membership
Posted on 16th June 2011 (1 month ago) #
hi
don't know about the hack but adding this to theme functions.php should do it
adding this option to the profile setting will need some bp hook work.

///////////////////////////////////////////////////////////////////////
/// check if is friend
///////////////////////////////////////////////////////////////////////
function bp_displayed_user_is_friend() {
global $bp;
if ( bp_is_profile_component() || bp_is_member() ) {
if ( 'is_friend' != BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $bp->displayed_user->id ) )
bp_core_redirect( $bp->root_domain . '/' );
// redirect to main site coz displayed user are not friend
}
}
add_filter('get_header','bp_displayed_user_is_friend',3);
cheers