BuddyPress hack: Remove ‘Send Private Message’ for non-friends
A quick hack to only display the ‘Send Private Message’ for friends. First we’ll create a simple check function for your functions.php or bp-custom.php file:
function my_is_friend_check( $friend_id = false) {
global $bp;
if ( is_site_admin() )
return true;
if ( !is_user_logged_in() )
return false;
if (!$friend_id) {
$potential_friend_id = $bp->displayed_user->id;
} else {
$potential_friend_id = $friend_id;
}
if ( $bp->loggedin_user->id == $potential_friend_id )
return false;
if (friends_check_friendship_status($bp->loggedin_user->id, $potential_friend_id) == 'is_friend')
return true;
return false;
}
Then edit the default theme file: /members/single/member-header.php and look for the ‘Send Private Message’ check and change it to:
if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_private_message_link' ) && my_is_friend_check() ) :
**NOTE**
@r-a-y has created a buddypress plug-in to remove this functionality:
Plugin: BuddyPress Private Messages for Friends Only

May 17th, 2010 at 9:02 am
[...] Private Message For Friends Only, written by r-a-y. Previously, you could accomplish this through a hack posted by Rich Fuller. Now all you have to do is download this plugin and drop it into your site to [...]