public function actionAddToModerator() { if (Yii::$app->user->isGuest) { echo json_encode(['status' => 0]); return; } $clubId = Yii::$app->request->post('clubId'); $userId = Yii::$app->request->post('userId'); $role = Club::getUserRole($clubId, Yii::$app->user->getId()); $userRole = Club::getUserRole($clubId, $userId); if ($role == 1 && $userRole == 3) { Club::addToModerator($clubId, $userId); echo json_encode(['status' => 1]); } else { echo json_encode(['status' => 0]); } }