Yeah, about that… You’re right, obviously, I just assumed that since bp_pre_user_query existed, a group equivalent did as well, but apparently not! As you can imagine, I tried everything I could think of in order to make it work somehow.
Anyway, I did the changes you proposed with the added custom query (like this)
function antares_get_groups() {
global $wpdb;
$sql = "SELECT g.id
FROM
{$wpdb->prefix}user_league_prediction as p,
{$wpdb->prefix}bp_groups_members as m,
{$wpdb->prefix}bp_groups as g
WHERE
g.id = m.group_id AND m.user_id = p.user_id
GROUP BY
m.group_id";
$buff = array();
$result = $wpdb->get_results( $sql , OBJECT );
foreach ($result as $row) {
$buff[]= $row->id ;
}
$query_str= implode (',', $buff);
return $query_str;
}
And it works! The only issue now is with the pagination, because even though it’s reading the number of groups correctly and displaying them on the list, when I click on the numbers it just doesn’t do anything. I checked the web console and the parameter 2&num is being passed correctly but it doesn’t do a thing. I suspect this is another problem with ajax.