code: public function actionBlock($id, $back = 'index')
      {
          if ($id == \Yii::$app->user->getId()) {
              \Yii::$app->getSession()->setFlash('danger', \Yii::t('user', 'You can not block your own account'));
          } else {
              $user = $this->findModel($id);
              if ($user->getIsBlocked()) {
                  $user->unblock();
                  \Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been unblocked'));
              } else {
                  $user->block();
                  \Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been blocked'));
              }
          }
          $url = $back == 'index' ? ['index'] : ['update', 'id' => $id];
          return $this->redirect($url);
      }
docs: Blocks the user.
  @param  integer $id
  @param  string  $back
  @return \yii\web\Response