hello
i’m trying to impliment a “ban” on a user when an admin clicks “ban this user”… here’s the code.
public function actionBan($id)
{
$model=$this->loadModel(Yii::app()->user->id);
if($model->muted==1) { $model->roles_id=5; //you can only ban when they're already muted
$model->LastUpdate=time(); //LastUpdate from the database.
if($model->save()) {
$auth=Yii::app()->authManager;
$auth->revoke(Yii::app()->user->role,$model->id); //role is assigned to user upon login.
$auth->assign('banned',$model->id);
$this->redirect(array('listusers'));
}} else throw new Exception('Banning a User', 'Can\'t ban a user unless they are muted first.');
}