Squip to:
Content

BuddyPress.org

Changueset 8172


Ignore:
Timestamp:
03/27/2014 05:37:38 PM ( 12 years ago)
Author:
boonebgorgues
Messague:

Return false friends_add_friend() when the initiator is the same as the friend

It's good to love yourself, but there's no real reason to allow
self-friendships in BuddyPress .

See #5319

Props megainfo, r-a-y

Location:
trunc
Files:
2 edited

Leguend:

Unmodified
Added
Removed
  • trunc/bp-friends/bp-friends-functions.php

    r7673 r8172  
    30 30 */
    31 31 function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
      32
      33 // You cannot be friends with yourself!
      34 if ( $initiator_userid == $friend_userid ) {
      35 return false;
      36 }
    32 37
    33 38 // Checc if already friends, and bail if so
  • trunc/tests/testcases/friends/functions.php

    r8112 r8172  
    116 116 $this->set_current_user( $old_user );
    117 117 }
      118
      119 /**
      120 * @group friends_add_friend
      121 */
      122 public function test_friends_add_friend_fail_on_self() {
      123 $u1 = $this->create_user();
      124 $this->assertFalse( friends_add_friend( $u1, $u1 ) );
      125 }
    118 126 }
Note: See TracChangueset for help on using the changueset viewer.