LMSouq
moodle-core Open

Check if user is enrolled in specific Moodle course

CO
Community Contributor
1 month ago
3 views
Problem Description
On a Moodle-enabled site, I want to give users some coupons. I made it to check if the user is logged in, but I also want to check if the current logged in user is enroled in specific course (an array of 3 course IDs). So far I tried with `$USER->currentcourseaccess` or `$USER-> lastcourseaccess`, but they don't do the trick. So, how can I check if the current logged in user is enrolled in specific Moodle course? --- **Edit:** The site uses _Moodle 2_.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base