BP_Groups_Group::has_members( int $group_id )

Check whether a given group has any members.

Description

Parameters

$group_id

(int) (Required) ID of the group.

Return

(bool) True if the group has members, otherwise false.

Source

File: bp-groups/classes/class-bp-groups-group.php

	public static function has_members( $group_id ) {
		global $wpdb;

		$bp = buddypress();

		$members = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );

		if ( empty( $members ) )
			return false;

		return true;
	}

Changelog

Changelog
Version Description
BuddyPress 1.6.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.