bp_get_users_by_roles( $roles )

Gets a user by their role.

Description

Parameters

$roles

(Required)

Return

(array)

Source

File: bp-members/bp-members-functions.php

function bp_get_users_by_roles($roles) {
	$roles = (array) $roles;
	$users = array();

	foreach ($roles as $role) :
		$users_query = new WP_User_Query( array(
			'fields' => 'ID',
			'role' => $role,
		) );
		$results = $users_query->get_results();
		if ($results) $users = array_merge($users, $results);
	endforeach;

	return $users;
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.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.