Opened 8 years ago
Closed 8 years ago
#7573 closed enhancement (fixed)
BP_Group_Member_Query should support multiple group IDs
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.0 | Priority: | normal |
| Severity: | normal | Version: | 1.8 |
| Component: | Groups | Keywords: | needs-patch commit |
| Cc: |
Description
Sometimes it is useful to query for members from multiple groups.
Currently, we cannot do this with BP_Group_Member_Query since it only supports one group ID.
Attached patch allows for passing multiple group IDs.
Attachments (2)
Change History (14)
#2
follow-up:
↓ 3
@
8 years ago
@dcavins - You're right. The else condition is not necessary.
I guess I was just being extra cautious, but wp_parse_id_list() should handle most empty instances and default to array( 0 ), so we should be safe to remove the else condition.
#3
in reply to:
↑ 2
@
8 years ago
Replying to r-a-y:
@dcavins - You're right. The
elsecondition is not necessary.
I guess I was just being extra cautious, but
wp_parse_id_list()should handle most empty instances and default toarray( 0 ), so we should be safe to remove theelsecondition.
Not so fast! :)
I think we need an else condition, because wp_parse_id_list( array() ) does return an empty array. But maybe the else condition should be explicitly not made to work, like group_id = 0 or something. I was just wondering, could there be a passed arg that would be useful? I can't think of one.
Thanks again for this good idea!
#4
@
8 years ago
Well, if you're passing an empty array, then you're SOL :)
I suppose we could do something like this:
$group_ids = wp_parse_id_list( $this->query_vars['group_id'] ); $group_ids = ! empty( $group_ids ) ? $group_ids : array( 0 );
Feels a little unnecessary, but meh!
#5
@
8 years ago
- Keywords commit added
- Milestone changed from Awaiting Review to 3.0
if someone passes a null-ish value to group_id and if we don't explicitly support that already, we do not need to protect against developer stupidity. This is our lowest-level query function for Groups Members queries, and any handholding like this should happen up the chain.
tl;dr 02 patch looks good
#7
@
8 years ago
- Owner set to DJPaul
- Status changed from new to assigned
Far warning, I'm going to add this next week @r-a-y unless you say otherwise.
Hi @r-a-y-
I think this is a great idea. In your attached patch, what would trigger the else condition:
else { $group_ids_sql = $wpdb->prepare( "group_id = %d", $this->query_vars['group_id'] ); }Maybe if an empty array or empty string was passed into the function? I guess I'm wondering, is there a value that you could pass that would be stripped down to an empty array by
wp_parse_id_list(), but would be useful to do an equals check on?Thanks for setting me straight. :)