Skip to:
Content

BuddyPress.org

Opened 13 years ago

Closed 13 years ago

#3205 closed enhancement (fixed)

Usermeta parameters for bp_has_members()

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 1.5 Priority: normal
Severity: Version: 1.2.8
Component: Core Keywords:
Cc:

Description

As I mentioned in IRC, I would like to introduce params to bp_has_members() that will allow filtering by usermeta. See the attached patch for a very basic first pass.

The idea is this: users very frequently have a need to filter member lists based on an arbitrary criteria. (I'd say that over 50% of my projects require this.) The only real way to make this work at the moment is to put filters directly on the SQL query, but for obvious reasons this is not ideal. By adding meta_key and meta_value params to bp_has_members, we allow site builders to manipulate the loop much more efficiently.

The attached patch is a bare-bones approach. Ideally, I would have employed a full meta_query approach, as in WP 3.1 (which would have eased the transition to CPTs in BP 1.4). But that isn't easy to do right now, because of the URL-style querystring method used to pass arguments to bp_has_members(). But there is currently backpat support for meta_value and meta_key params in WP_Meta_Query, so even if we modify the way that these params work in BP 1.4, existing plugins/themes should upgrade pretty seamlessly.

Attachments (2)

3205.patch (6.3 KB) - added by boonebgorges 13 years ago.
3205-2.patch (6.6 KB) - added by boonebgorges 13 years ago.

Download all attachments as: .zip

Change History (4)

@boonebgorges
13 years ago

#1 @boonebgorges
13 years ago

Realized just after uploading that it'd be extra nice to pass the meta values along to the $members_template so they'd be easily accessible in the template. See 3205-2.patch.

#2 @boonebgorges
13 years ago

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

(In [4360]) Adds meta_key and meta_value params to bp_has_members() and related functions. Fixes #3205

Note: See TracTickets for help on using tickets.