Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 10 years ago

#4591 closed enhancement (wontfix)

search and Get Groups by Group Meta

Reported by: dennissmolek's profile DennisSmolek Owned by:
Milestone: Priority: normal
Severity: normal Version: 1.7
Component: Groups Keywords:
Cc: georgemamadashvili@…

Description

Currently there is no way to fetch groups by custom group meta. Groups are objects similar to users and even have meta but none of that data does anything site wide.

You should be able to add group meta fields like xprofile fields, then they would even become searchable.

With that there should also be a "meta-key" and "meta-vale" parameter added to groups_get_groups()

Right now that group data is great and useful, but requires a wpdb query to backtrack group ID's.

Attachments (1)

bp-groups-classes.diff (3.0 KB) - added by DennisSmolek 12 years ago.
First pass at a 1.7 patch to add group meta searching.

Download all attachments as: .zip

Change History (12)

#1 @DJPaul
12 years ago

  • Component changed from Core to Groups
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement

This might be a duplicate of an existing request, but yes.

@DennisSmolek
12 years ago

First pass at a 1.7 patch to add group meta searching.

#2 @DennisSmolek
12 years ago

  • Keywords dev-feedback has-patch added
  • Version set to 1.7

I did this for a site I'm working on and I think its super helpful so I went ahead and pulled 1.7 down and applied this to trunk. I think I could add the third table info purely in the conditional but for now this works.

Also, the two sets of queries are totally different which is weird. for example, one has g.gid = gm1.group_id as apart of a string, the lower one for the total count has is as an array. I followed suit for my changes but it could be unified to make sense.

#3 @boonebgorges
12 years ago

Thanks for the first patch, DennisSmolek.

You're right that the queries are built differently, which is kinda dumb. In the future we'll probably build a BP_Group_Query class along the lines of the new BP_User_Query, which'll fix some of these inconsistencies.

For this patch, we should probably only be performing the extra groupmeta join if there are actually search terms present, since these joins are pretty slow.

It would also be nice to have real meta_key/meta_value support - this patch doesn't attempt that. I don't think we necessarily have to introduce it all at the same time, of course. We could wait and shoot for a real meta_query in BP 1.8.

If the patch is applied as-is, it may result in some odd behavior, as when groupmeta is used to store numerical values. If you search for '2', for example, it would be odd if you got back group results where some random groupmeta iterator was '2' (like the member count). Maybe this is an edge case, but it's a bit worrisome. If we had proper meta_query functionality, we could just skip the search_terms join, and require proper meta queries for this sort of thing.

#4 @DJPaul
11 years ago

  • Milestone changed from Future Release to 1.8

DennisSmolek - interested in helping get this into BP 1.8?

#5 @boonebgorges
11 years ago

  • Keywords dev-feedback has-patch removed
  • Resolution set to duplicate
  • Status changed from new to closed

Already done! You can now pass a 'meta_query' param to bp_has_groups(). See r6950, #3521

#6 @DennisSmolek
11 years ago

I know with wp_meta_query you can pass LIKE, but can you also pass wildcards for partial matches?

#7 @boonebgorges
11 years ago

We are using WP_Meta_Query to construct the subquery. So you should be able to do anything here that you can in WP. Though please do test to make sure that's the case, and report any problems you find.

#8 @DennisSmolek
11 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

Ok I notice that this does allow for querying by meta, but does not solve the ability to search by meta.

I still view this is as a need, im working on it now and will post my results when I'm done.

#9 @boonebgorges
11 years ago

  • Milestone changed from 1.8 to Future Release

I'm not convinced that searching by meta is something that we want by default. For example, BP Groupblog stores the id of the group's associated blog in groupmeta. Should a search for '123' return the group that is associated with blog 123? Seems odd to me. However, you're welcome to propose a patch.

#10 @Mamaduka
10 years ago

  • Cc georgemamadashvili@… added

I think this should be left to group meta query compare param.

#11 @boonebgorges
10 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

I think this should be left to group meta query compare param.

Agreed. Feel free to reopen if you've got a patch that demonstrates the behavior you'd like to see. Thanks.

Note: See TracTickets for help on using tickets.