diff --git a/lib/modules/ConsultationModule.class.php b/lib/modules/ConsultationModule.class.php
index ca5654d3725726bf23c214c8c50381902ce3a939..acc2cb4cd6dffecafdf7a93b798f2e80aa19e74b 100644
--- a/lib/modules/ConsultationModule.class.php
+++ b/lib/modules/ConsultationModule.class.php
@@ -9,6 +9,52 @@ class ConsultationModule extends CorePlugin implements StudipModule, SystemPlugi
     {
         parent::__construct();
 
+        // Update consultation events for the course when a member changes
+        foreach (['UserDidEnterCourse', 'UserDidLeaveCourse'] as $event) {
+            NotificationCenter::on($event, function ($event, $course_id) {
+                $course = Course::find($course_id);
+                if ($course) {
+                    ConsultationSlot::findEachBySQL(
+                        function (ConsultationSlot $slot) {
+                            $slot->updateEvents();
+                        },
+                        "JOIN consultation_blocks USING (block_id)
+                         WHERE range_id = ? AND range_type = 'course'",
+                        [$course_id]
+                    );
+                }
+            });
+        }
+
+        // Update consultation events for the course when a member changes
+        foreach (['InstituteMemberDidCreate', 'InstituteMemberDidDelete'] as $event) {
+            NotificationCenter::on($event, function ($event, InstituteMember $member) {
+                ConsultationSlot::findEachBySQL(
+                    function (ConsultationSlot $slot) {
+                        $slot->updateEvents();
+                    },
+                    "JOIN consultation_blocks USING (block_id)
+                      WHERE range_id = ? AND range_type = 'institute'",
+                    [$member->institut_id]
+                );
+            });
+        }
+
+        NotificationCenter::on('UserDidLeaveCourse', function ($event, $course_id) {
+            // Delete consultation events for the user and course
+            $course = Course::find($course_id);
+            if ($course) {
+                ConsultationSlot::findEachBySQL(
+                    function (ConsultationSlot $slot) {
+                        $slot->updateEvents();
+                    },
+                    "JOIN consultation_blocks USING (block_id)
+                     WHERE range_id = ? AND range_type = 'course'",
+                    [$course_id]
+                );
+            }
+        });
+
         NotificationCenter::on('UserDidDelete', function ($event, $user) {
             // Delete consultation bookings and slots
             ConsultationBooking::deleteByUser_id($user->id);