diff --git a/course/unenrol.php b/course/unenrol.php index e007e88cc39..bf7e55c1902 100644 --- a/course/unenrol.php +++ b/course/unenrol.php @@ -14,6 +14,13 @@ $userid = optional_param('user', 0, PARAM_INT); //course $confirm = optional_param('confirm', 0, PARAM_BOOL); + if($userid == $USER->id){ + // the rest of this code assumes $userid=0 means + // you are unassigning yourself, so set this for the + // correct capabiliy checks & language later + $userid = 0; + } + if (! $course = get_record('course', 'id', $id) ) { error('Invalid course id'); }