From 7b7f44e0ab21734d2d575b9c549348f49af0a23c Mon Sep 17 00:00:00 2001 From: TamaroWalter Date: Thu, 18 Jan 2024 11:04:42 +0100 Subject: [PATCH] first attempt to fix bug --- classes/task/send_daily_mail.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/classes/task/send_daily_mail.php b/classes/task/send_daily_mail.php index 7c2fa1cda9..3f4913a961 100644 --- a/classes/task/send_daily_mail.php +++ b/classes/task/send_daily_mail.php @@ -57,6 +57,11 @@ public function execute() { // Fill the $mail array. foreach ($userdata as $row) { $currentcourse = $DB->get_record('course', array('id' => $row->courseid), 'fullname, id'); + // Check if the user is enrolled in the course, if not, go to the next row. + if (!is_enrolled(\context_course::instance($row->courseid), $user->userid, '')) { + continue; + } + $currentforum = $DB->get_record('moodleoverflow', array('id' => $row->forumid), 'name, id'); $coursemoduleid = get_coursemodule_from_instance('moodleoverflow', $row->forumid); $discussion = $DB->get_record('moodleoverflow_discussions', array('id' => $row->forumdiscussionid), 'name, id');