Moodle in English: New course: Moodle development environment moodle.org - get the latest breaking news, showbiz & celebrity photos, sport news & rumours, viral videos and top stories from moodle.org Daily Mail and Mail on Sunday newspapers.
Hello Amir. Welcome to Moodle development.
For the start, you may find the Moodle Plugin Development Basics course at https://learn.moodle.org/ useful for you.
Beware that
after require login hook would be called pretty frequently. Basically on almost every page request. There might be more effective way to implement this. Event subscription for the
core\event\user loggedin comes to my mind as a good candidate.
There are a few plugins already that seem to implement automatic enrolment once a certain event occurs - please browse through https://moodle.org/plugins/?q=type:enrol Some of they may be a good starting point for your functionality.