Skip to:
Content

BuddyPress.org

Ticket #5319: 5319.01.patch

File 5319.01.patch, 1.0 KB (added by r-a-y, 10 years ago)
  • bp-friends/bp-friends-functions.php

     
    3030 */
    3131function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
    3232
     33        // You cannot be friends with yourself!
     34        if ( $initiator_userid == $friend_userid ) {
     35                return false;
     36        }
     37
    3338        // Check if already friends, and bail if so
    34         $friendship = new BP_Friends_Friendship;
    35         if ( (int) $friendship->is_confirmed ) {
     39        if ( friends_check_friendship( $initiator_userid, $friend_userid ) ) {
    3640                return true;
    3741        }
    3842
    3943        // Setup the friendship data
     44        $friendship = new BP_Friends_Friendship;
    4045        $friendship->initiator_user_id = $initiator_userid;
    4146        $friendship->friend_user_id    = $friend_userid;
    4247        $friendship->is_confirmed      = 0;
    4348        $friendship->is_limited        = 0;
    4449        $friendship->date_created      = bp_core_current_time();
    4550
    46         if ( !empty( $force_accept ) ) {
     51        if ( ! empty( $force_accept ) ) {
    4752                $friendship->is_confirmed = 1;
    4853        }
    4954