[buddypress-trac] [BuddyPress Trac] #5457: Improvements to friends_get_friend_user_ids()

buddypress-trac noreply at wordpress.org
Tue Mar 11 22:38:35 UTC 2014


#5457: Improvements to friends_get_friend_user_ids()
-------------------------+-----------------------------
 Reporter:  r-a-y        |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Friends      |    Version:
 Severity:  normal       |   Keywords:  has-patch
-------------------------+-----------------------------
 The `friends_get_friend_user_ids()` function gets the user IDs that a user
 is friends with.

 There are two extra parameters - `$friend_requests_only` and `$assoc_arr`.

 If `$friend_requests_only` is set to true, only user IDs that initiated
 the friendship request are returned.  However, currently this grabs
 pending friendships (`is_confirmed = 0`).  It would be useful if we could
 also grab confirmed friendships as well by omitting the `is_confirmed = 0`
 clause.

 If `$assoc_arr` is set to true, then an associated array like:

 {{{
 array(
         array( 'user_id' => x ),
         array( 'user_id' => x ),
 )
 }}}

 is returned.  This isn't very useful and isn't used within the internal
 codebase of BuddyPress.  I also checked the WP.org repo and no plugin
 appears to be using this functionality.

 Therefore, the attached patch removes the `$assoc_arr` argument and
 replaces it with `$get_all`, which allows us to grab all friendships
 regardless of pending or confirmed status.

 Attached patch also changes how user IDs are fetched.  If
 `$friend_requests_only` is set to true, we only need to select the
 `initiator_user_id` column and avoids having to select two columns and do
 a foreach loop.

 Wanted to get something up on Trac before I forget to post about it.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5457>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list