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() ) :


@r-a-y has created a buddypress plug-in to remove this functionality:
Plugin: BuddyPress Private Messages for Friends Only

This entry was posted in Tech and tagged , . Bookmark the permalink.

One Response to BuddyPress hack: Remove ‘Send Private Message’ for non-friends

  1. Pingback: Kill BuddyPress Private Messaging Spam With New Must-Have Plugin - WordPress MU and BuddyPress plugins, themes, support, tips and how to's

Leave a Reply