Skip to:
Content

BuddyPress.org

Opened 2 months ago

Closed 4 weeks ago

Last modified 4 weeks ago

#9205 closed enhancement (fixed)

Move some BP_User_Query::populate_extras() properties to hooks

Reported by: r-a-y's profile r-a-y Owned by: espellcaste's profile espellcaste
Milestone: 15.0.0 Priority: normal
Severity: normal Version: 1.7
Component: Core Keywords: dev-feedback has-patch
Cc:

Description

In BP_User_Query::populate_extras(), we hook the XProfile component and Friends component to add in extra data to the user query results. See bp_xprofile_filter_user_query_populate_extras() and bp_friends_filter_user_query_populate_extras().

However, we hardcode the last activity timestamp, total friend count, last activity update and meta_key/meta_value (if passed) to the user query results. What if we do not want to query and return these items to the user results?

This patch moves the hardcoded items to hooks, so it is possible for developers to remove some of these fetched properties from the BP user query.

Attachments (1)

9205.01.patch (8.3 KB) - added by r-a-y 2 months ago.

Download all attachments as: .zip

Change History (11)

@r-a-y
2 months ago

#1 @espellcaste
2 months ago

A nice addition.

Only two suggestions comes to mind:

Add @global wpdb $wpdb WordPress database object. to the new bp_members_filter_user_query_populate_extras_meta function.

And change the references from add_filter to add_action since you are modifying the user query but not returning anything. This "issue" is true to the examples you shared too. See.

It's true that it works as is but it is semantically incorrect.

#2 @espellcaste
2 months ago

  • Keywords changes-requested added
  • Milestone changed from Awaiting Review to Up Next

I'm bumping this ticket to the next version only because we plan to release BP 14.0 in 5 days. But @imath can decide here if we can add it now. Seems low risk to me.

#3 @imath
2 months ago

Hi @r-a-y & @espellcaste

Thanks a lot for your contributions, I agree with @espellcaste let’s take some more time to work on it during next release 👍

#4 @imath
2 months ago

  • Milestone changed from Up Next to 15.0.0

#5 follow-up: @espellcaste
5 weeks ago

@r-a-y I can make the changes, if you want. What do you think?

#6 in reply to: ↑ 5 @r-a-y
5 weeks ago

Replying to espellcaste:

@r-a-y I can make the changes, if you want. What do you think?

Feel free to make the changes, espellcaste!

#7 @espellcaste
5 weeks ago

  • Owner set to espellcaste
  • Status changed from new to assigned

#8 @espellcaste
4 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 13994:

Move some BP_User_Query::populate_extras() properties to custom action hooks.

The action of populating class properties were moved from the populate_extras method into action hooks, allowing developers to remove any of them, if needed.

Props r-a-y and imath.

Fixes #9205

#9 @espellcaste
4 weeks ago

  • Keywords changes-requested removed

This ticket was mentioned in Slack in #buddypress by espellcaste. View the logs.


4 weeks ago

Note: See TracTickets for help on using tickets.