I was following this thread - https://moodle.org/mod/forum/discuss.php?d=210828#p918983
The thread mentions the difficulty or non-existent method of unenrolling students manually if they were originally enrolled through database enrolment.
I got around it by writing a query to delete them but it's not ideal.
In the thread, it mentioned creating a special role and his script scans the table for those users with that special role and unenrols them from the course via a scheduled script.
I was thinking of doing something similar but using a trigger. The trigger would automatically unenrol that user from the course when the administrator or instructor adds this add special role to the user.
Does this make sense? How would I go about to do this?