The moodle allows users / students to do self enrollment in the course as well as you can do the “enroll key” based enrollment if you wants to allow only specific known users to enroll in the course.
Below we will see, how to enable self enrollment for the students. This will also remove “You can not enroll yourself in this course.” message from the registered users course pages and add a button to enroll and will not need a key.
then, click on “Settings” infront of “Self enrolment” and deselect “Require enrolment key” from settings page.
Once this is enabled in Plugins now, you have configure individual course for whether you want to allow the course to be visible to “Guest” or “Self Enrollment”
For this, click on the course you want to configure, then on opened page, it will show “Course Administration” in sidebar, the follow like below,
“Course Administration -> Users -> Enrolment methods” “Add Method -> Self Enrollment” don’t enter anything in “Enrolment key” and click save.
Now, when a students logs in to the portal and clicks on that perticular course, he/she can see the page with message as,