I've such kind of situation here : I'm login into moodle via SSO(using moodle-auth_userkey) which is working well, now I want to auto enroll a selected course to logged in user and I'm using auto_enrol plugin for this, so there are two condition to enroll course which is.
1. when user logged in : I follow with this one, but all courses (which has an instance of auto enroll) enrolled while I want a specific course to enroll.
2. when loading the course : I followed this one as well with URL http://localhost/rs/course/view.php?id=14 but it shows me "This course is currently unavailable to students", so I showed this course from configuration(unhide) but I don't want to allow them to visible to users already.
Please help me, how can I achieve this.
I found solution for above situation, here I want to share it with you, so someone can get help from that.
First create session based on if `wantsurl` isn't empty in 'moodle/auth/userkey/auth.php' after line number 162 like.
While I cannot help you with your query, I have used the auto-enroll plugin and found a serious issue.
I am not sure if it is exactly because of the auto_enroll plugin; but that was the only addition I made to my site before I ran into the issues below.
The enroll into course 'when course is opened' works fine; but the 'enroll on login' created issues for me.
All the users of my site (old and new) got enrolled into the courses where the auto_enroll plugin was used.
For some reason, the installation size started increasing rapidly and within one day, the Moodle installation size went from 5.5 GB to around 50 GB, which is the limit of my server space.
In less than 24 hours, the website crashed.
I had to reinstall everything from a older back-up.
So, if you have enabled 'enroll on login' option, keep an eye on the installation size.