Skip to:

Opened 4 months ago

Last modified 8 weeks ago

#9031 new enhancement

bp_has_groups has missing parameter to fetch groups based on the group's creator or admin

Reported by: vapvarun's profile vapvarun Owned by:
Milestone: Up Next Priority: normal
Severity: normal Version: 11.4.0
Component: Groups Keywords:


During our client assistance, we came across an issue wherein we were unable to list groups using the bp_has_groups function based on the group's creator or admin.

The function accepts several parameters to filter the groups, such as 'user_id', 'group_id', 'search_terms', etc. However, none of these parameters directly allow you to filter groups based on the group's creator or admin.

The user_id parameter determines the results you will see based on the groups you have joined..

Change History (4)

#1 @vapvarun
4 months ago

got a workaround by creating a list using SQL for the creator_id

function vap_get_created_groups_by_user($user_id) {
    global $wpdb;
    $bp = buddypress();

    // Modify the SQL to select only the 'id' column
    $sql = $wpdb->prepare(
        "SELECT id FROM {$bp->groups->table_name} WHERE creator_id = %d",

    // Fetch and return the results
    $results = $wpdb->get_results($sql);

    // Extract just the group IDs from the results
    $group_ids = array_map(function($group) {
        return $group->id;
    }, $results);

    // Convert the array of IDs into a comma-separated string
    return $group_ids;

and then sending the same as the argument using the included parameter

$args = array('include' =>  $group_ids); // Modify this according to your needs

Using bp_has_groups() twice with different parameters inside a custom tab and the loop template can cause conflicts or unintended behavior.
Having a custom template for group-loop was necessary to achieve the desired result.

Last edited 4 months ago by vapvarun (previous) (diff)

#2 @imath
4 months ago

  • Milestone changed from 11.5.0 to Up Next

Thanks for your report @vapvarun let's talk about it during next dev cycle.

#3 @imath
4 months ago

  • Milestone changed from Up Next to 14.0.0

#4 @espellcaste
8 weeks ago

  • Milestone changed from 14.0.0 to Up Next
Note: See TracTickets for help on using tickets.