Enrollment plugins have a similar structure to authentication plugins. However, Moodle does not provide an extensible base class for creating enrollment plugins. Instead, it relies on a consistent naming convention for the class names and member functions. The end result is similar, but not quite as clean from an object-oriented design perspective.
As with all of the other plugins that we have covered, our module needs its own folder. Enrollment plugins go into the /enrol
folder.
Each enrollment plugin needs an enrol.php
file. Each enrollment plugin needs to include the required base library:
require_once($CFG->dirroot.'/enrol/enrol.class.php');
Within this file, there must be an enrollment class defined. The naming convention for this class is: enrolment_plugin_<name>
. Here is an example from the external database enrollment plugin from the Moodle core:
class enrolment_plugin_database {