Opened 7 years ago
Closed 7 years ago
#7601 closed feature request (fixed)
Add user_id to $results array for easier filtering of autocompletes
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Members | Keywords: | dev-feedback |
Cc: |
Description
When trying to filter users in autocomplete, it would be better if user_id was included in the $results array, so a user lookup would not be required to get the user_id from the user_nicename
bp-core/classes/class-bp-members-suggestions.php
<?php foreach ( $user_query->results as $user ) { $result = new stdClass(); $result->ID = $user->user_nicename; $result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) ); $result->name = bp_core_get_user_displayname( $user->ID ); $results[] = $result; }
Could change to:
<?php foreach ( $user_query->results as $user ) { $result = new stdClass(); $result->ID = $user->user_nicename; $result->user_id = $user->ID; $result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) ); $result->name = bp_core_get_user_displayname( $user->ID ); $results[] = $result; }
Thank You
Change History (5)
#1
@
7 years ago
- Component changed from Core to Members
- Keywords dev-feedback added
- Milestone set to Under Consideration
This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.
7 years ago
This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.
7 years ago
Note: See
TracTickets for help on using
tickets.
On one hand, sure, I'm OK to add this. I looked into core's
get_user_by( 'slug', ... )
and it does have a cache for look-ups byuser_nicename
, but I can understand the developer convenience of having the ID, given that most functions take user IDs.On the other hand, this data is passed to
bp_ajax_get_suggestions()
, which is sent on page requests when authenticated and Friends is enabled and the user has friends. We'd be exposing user IDs, which I'm not *sure* we do anywhere else (or if we should stop doing that, I know we've had similar "complaints" about theuser_nicename
in the URL before).Moving to a second opinion.