[buddypress-trac] [BuddyPress] #5157: Modify Add Friend button logic based on who initiated request

buddypress-trac noreply at wordpress.org
Thu Aug 29 17:53:10 UTC 2013


#5157: Modify Add Friend button logic based on who initiated request
-------------------------+------------------------------
 Reporter:  terraling    |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Core         |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------

Comment (by terraling):

 Of course, in my haste to make my first contribution I left a bit of
 redundant code in place in bp-friends-classes.php.

 The correct version has been uploaded with the definition of
 check_is_friend as follows:


 {{{
 function check_is_friend( $loggedin_userid, $possible_friend_userid ) {
                 global $wpdb, $bp;

                 if ( empty( $loggedin_userid ) || empty(
 $possible_friend_userid ) )
                         return false;

                 $result = $wpdb->get_results( $wpdb->prepare( "SELECT id,
 is_confirmed, initiator_user_id FROM {$bp->friends->table_name} WHERE
 (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id =
 %d AND friend_user_id = %d)", $loggedin_userid, $possible_friend_userid,
 $possible_friend_userid, $loggedin_userid ) );
                 if ( !empty( $result ) ) {
                         if ( 0 == (int) $result[0]->is_confirmed ) {
                                 if ( $loggedin_userid ==
 $result[0]->initiator_user_id ) {
                                         return 'pending';
                                 } else {
                                         return 'respond';
                                 }
                         } else {
                                 return 'is_friend';
                         }
                 } else {
                         return 'not_friends';
                 }
         }
 }}}

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5157#comment:1>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list