diff --git a/controllers/matrix_chat.php b/controllers/matrix_chat.php
index 5c1507f4dc5d25298776c978ded40469437ca905..ffe3f437bfae2888d32361e0f628271854657be6 100644
--- a/controllers/matrix_chat.php
+++ b/controllers/matrix_chat.php
@@ -41,6 +41,10 @@ class MatrixChatController extends AuthenticatedController
         Navigation::activateItem('/course/matrix/matrix_chat');
 
         $this->noChat = false;
+        $this->noMemberHint = false;
+        $this->showAccountHint = false;
+        $this->account = null;
+        $this->hasToCreate = false;
 
         $member = CourseMember::find([$this->course->id, User::findCurrent()->id]);
 
@@ -71,13 +75,10 @@ class MatrixChatController extends AuthenticatedController
                 $this->account->store();
             }
 
-            $this->hasToCreate = false;
             if ($this->account || !Config::get()->MATRIX_AUTO_CREATE_ACCOUNTS) {
                 if (!($room = MatrixRoom::findOneByRange_id(Course::findCurrent()->id))) {
                     $this->hasToCreate = true;
                 } else {
-                    $this->hasToCreate = false;
-
                     if ($this->account) {
                         if (Config::get()->MATRIX_AUTO_CREATE_ACCOUNTS) {
                             $room->requireMembership($this->account->getLinkedAccount());
diff --git a/views/matrix_chat/index.php b/views/matrix_chat/index.php
index 5662ea84c866c6599dce2db74efdd29b9d88a5d9..dcaaf7270637b7f8b77784f79c0e363ebbc00ea8 100644
--- a/views/matrix_chat/index.php
+++ b/views/matrix_chat/index.php
@@ -1,3 +1,14 @@
+<?php
+/**
+ * @var bool $noMemberHint
+ * @var bool $showAccountHint
+ * @var MatrixAccount $account
+ * @var MatrixChatController $controller
+ * @var bool $no_account_wanted
+ * @var bool $hasToCreate
+ * @var bool $noChat
+ */
+?>
 <? if ($noMemberHint) : ?>
     <div class="messagebox messagebox_warning">
         <p>