Answer the question
In order to leave comments, you need to log in
How to display all users by id in dataProvider in yii2 having an array with user ids?
With the help I get an array with ids of users of this role
$auth = Yii::$app->authManager;
$role = $auth->getUserIdsByRole($name);
$searchModel = new UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->query->andFilterWhere(['id' => 1]);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
Answer the question
In order to leave comments, you need to log in
$userIdsByRole=$auth->getUserIdsByRole($name);
$dataProvider->query->andFilterWhere(['IN','id',$userIdsByRole]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question