I have tried to find the new way get the total in a user group
in PHP (plugin), but not having much luck…
Please help Assume it starts with Craft::$app->users ?
ベストアンサー
Use the ActiveRecord
from Yii2
$userGroupId = 1//insert your usergroup Id here
$users = User::find()->groupId($userGroupId)->all();
またはハンドルを介して
$userGroup = Craft::$app->userGroups->getGroupByHandle('handle');
$users = User::find()->group($userGroup)->all();
If you mean the number of users in a group with total you just
have to do count()
instead of all()
あなたができる各グループのユーザーを取得するには
foreach(Craft::$app->userGroups->getAllGroups() as $userGroup){
$users = User::find()->group($userGroup)->all();
}