Your Moodle version

Enrolment: Enrol by user profile fields

Maintained by Picture of Nicolas Dunand Nicolas Dunand
This plugin allows users to be enrolled according to any value stored in their user profile.

This plugin allows users to be enrolled according to any value stored in their user profile. If you use an external authentication scheme (LDAP, Shibboleth), you can store values in hidden user fields of the users' Moodle profile, and then use these values to automatically enrol users if some courses.


Screenshot #0


Picture of Nicolas Dunand
Nicolas Dunand (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Narissa Bayler
    Wed, Jul 13, 2016, 12:26 PM
    Hi. Am running Moodle 2.8. Installed the plugin without any problems and it's showing as available (eye open) in the enrolments plugins however it is not present in any courses' drop down box for adding it as an enrolment method. Any suggestions or help would be appreciated
  • Picture of Nicolas Dunand
    Wed, Jul 13, 2016, 12:58 PM
    Hi Narissa,

    To activate the plugin you have to check its settings (in the Administration block -> Site Administration -> Plugins -> Enrolments) and make sure at least one field is selected.
  • Picture of Narissa Bayler
    Fri, Jul 15, 2016, 7:22 AM
    Hi Nicolas
    I'm not sure if I'm having a dense moment but I'm assuming you're referring to Site admin > plugins > enrolments > Enrol by user profile or did you mean something else?
    This is all I get on that page:
  • Picture of Nicolas Dunand
    Fri, Jul 15, 2016, 2:41 PM
    Hi Narissa,

    I see. This is likely because this plugin only works with additional profile fields – so the only fields you could select here would be some of these. To define additional profile fields, go to Site admin > Users > Accounts > User profile fields.
  • Picture of Peter Ward
    Fri, Jul 22, 2016, 8:07 PM
    Hi Nicolas,
    I need to check something with you that you answered for me previously.

    You said.....
    The enrollments are processes as follows:
    a.) When a user logs in, all rules are check to see whether any apply. If so, the user is enrolled in any relevant courses before arriving on the landing page.
    b.) There is a cron job running every 6 hours (because this is heavier lifting) to check for all rules, enrolling any users that need to be enrolled.

    So I have now.....
    Just applied your plugin to a moodle v3.1 and configured it just as I did in moodle v3.0
    My tables are prefixed mood_ and not mdl_ so I changed your edit.php file to match

    But my user isn't logged in as per a) above. Maybe there are other references to mdl_ I need to change, please advise

    also with regards b) what is the name of the cron job that runs?

    Many thanks in advance.

  • Wazza
    Fri, Jul 22, 2016, 10:21 PM
    Any time until Moodle 3.1 support?
  • Picture of Nicolas Dunand
    Mon, Jul 25, 2016, 1:38 PM
    Hi Peter,

    There are a couple spots in edit.php, but that's the only file that needs patching. The upcoming release addresses this issue, and you won't have to patch it anymore.

    The cron function is in lib.php.
  • Picture of Nicolas Dunand
    Mon, Jul 25, 2016, 1:48 PM
    Hi Richard,

    Official Moodle 3.1 support is available as of now.
  • Picture of Peter Ward
    Tue, Jul 26, 2016, 12:06 AM
    Thanks Nicolas.

    also with regards b) what is the name of the cron job that runs?


  • Picture of Andras Koharek
    Thu, Aug 4, 2016, 3:40 AM
    Dear Nicolas,

    I added and set up the plugin (latest version), and have an issue. As you can see from your debug message your plugin finds two cases when the the enrolment should happen:

    sqlquery= SELECT DISTINCT FROM mdl3_user u RIGHT JOIN mdl3_user_info_data d1 ON d1.userid = WHERE (d1.fieldid = 4 AND ( = 'aaaaa' OR LIKE '%;aaaaa' OR LIKE 'aaaaa;%' OR LIKE '%;aaaaa;%' ))
    line 102 of \enrol\attributes\edit.php: call to debugging()
    countusers= 2
    line 104 of \enrol\attributes\edit.php: call to debugging()

    However when I push the force enrollment button nothing happens, even when a user log in no enrolment is happening. When the loged in user wants to enroll manualy Moodle says: you can not enrol yourself ... which is right as your plugin is the only one added to the course.

    Please help what is going wrong.

  • Picture of Andras Koharek
    Thu, Aug 4, 2016, 4:21 AM
    just one think to add: when I hit the force enrollment button an ajax window pops up stating this will (re)enroll all users corresponding to this rule. I push OK and nothing happens. When I hit the "purge enrollments" just to test same pop up comes and when I push the ok few sec later an other pop up comes stating, "ok, enrollments are purged". Hope this help to solve the issue.
    thanks in advance
  • Picture of Nicolas Dunand
    Thu, Aug 4, 2016, 3:01 PM
    Hi Andras,

    I've just sent you a private message to sort this out. Once this is sorted I'll post back here if some relevant info came up for other users of this plugin.
  • Picture of Nicolas Dunand
    Thu, Aug 4, 2016, 8:50 PM
    To people using this plugin on a Moodle where the database type is Oracle or MSSQL, be aware that there is a known bug that prevents the enrollments to occur properly.

    I'm currently working on this, and will hopefully provide a new release addressing this issue soon.

    For more information, see
  • Picture of Narissa Bayler
    Mon, Aug 8, 2016, 12:24 PM
    It appears the plugin doesn't take into account that not all Moodle databases use the old mdl_ prefix. I'm getting an error saying that table 'moodle.mdl_user' doesn't exist which is correct, we have never used the mdl_ prefix. I have edited your source code to get it working so far but it would be good if this could be fixed in the plugin. Cheers
  • Picture of Nicolas Dunand
    Mon, Aug 8, 2016, 5:22 PM
    Hi Narissa,

    Thanks, but this has been corrected in recent versions. Which version of the plugin are you using?
1 2 3 4 5 6 7
Please login to post comments