diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 67874028e55..39b6d2e4547 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -55,6 +55,11 @@ if (!$forum) { throw new \moodle_exception('Unable to find forum with id ' . $discussion->get_forum_id()); } +$course = $forum->get_course_record(); +$cm = $forum->get_course_module_record(); + +require_course_login($course, true, $cm); + $managerfactory = mod_forum\local\container::get_manager_factory(); $capabilitymanager = $managerfactory->get_capability_manager($forum); $urlfactory = mod_forum\local\container::get_url_factory(); @@ -71,11 +76,6 @@ $discussiondatamapper = $datamapperfactory->get_discussion_data_mapper(); $discussionrecord = $discussiondatamapper->to_legacy_object($discussion); $discussionviewurl = $urlfactory->get_discussion_view_url_from_discussion($discussion); -$course = $forum->get_course_record(); -$cm = $forum->get_course_module_record(); - -require_course_login($course, true, $cm); - // move this down fix for MDL-6926 require_once($CFG->dirroot . '/mod/forum/lib.php');