Skip to:
Content

BuddyPress.org

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#9205 closed enhancement (fixed)

Move some BP_User_Query::populate_extras() properties to hooks

Reported by: r-a-y Owned by: espellcaste
Priority: normal Milestone: 15.0.0
Component: Core Version: 1.7
Severity: normal 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 years ago.

Download all attachments as: .zip

Change History (11)

@r-a-y
2 years ago

#1 @espellcaste
2 years 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 years ago

  • Keywords changes-requested added
  • Milestone Awaiting Review β†’ 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 years 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 years ago

  • Milestone Up Next β†’ 15.0.0

#5 follow-up: @espellcaste
2 years ago

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

#6 in reply to: ↑ 5 @r-a-y
2 years 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
2 years ago

  • Owner set to espellcaste
  • Status new β†’ assigned

#8 @espellcaste
2 years ago

  • Resolution β†’ fixed
  • Status assigned β†’ 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
2 years ago

  • Keywords changes-requested removed

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


2 years ago

Note: See TracTickets for help on using tickets.