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
  • Stephanie Gerald
    Thu, Aug 20, 2015, 12:14 AM
    Hello! I'm also trying to find some sort of documentation on how I add in my own custom profile fields? I've tried editing the "jquery.booleanEditor.js" file that some others have commented here about, but my profile field never shows up in the profile field drop-down within the course enrollment plugin. How do we add our custom profile fields to the drop-down list?
  • Picture of Frankle Lee 李智高
    Tue, Sep 8, 2015, 11:38 PM
    will this work on 2.9? Any develop plan for that?
  • Larry Lippke
    Fri, Sep 25, 2015, 12:19 AM
    I don't want to automatically enroll everyone with specific content in a profile field, but use that as a filter for people wanting to self enroll. That is, when someone intentionally attempts to enroll in a course, the plugin checks the user's profile. If the condition is met, the user is enrolled. If the condition is not met, the user is not permitted to enroll. Is this the way this plugin works?
  • Picture of Nicolas Dunand
    Wed, Oct 14, 2015, 12:58 PM

    First, thanks for everyone's feedback. The new version (2.0) if this plugin is now available, the main enhancements are:

    - official support for Moodle 2.7 to Moodle 2.9
    - the enrolment plugin does not have to rely on Shibboleth authentification any more
    - you can now easily define the custom user profile fields you wish to use
  • Picture of dcm st
    Wed, Oct 21, 2015, 5:20 PM
    I installed your plugin but I can't see it in the "add method" list. What am I doing wrong? I'm on moodle 2.9.3, the plugin is already activated.
  • Picture of Nicolas Dunand
    Wed, Oct 21, 2015, 6:23 PM

    Please ensure the following :

    1.- In Site Administration > Users > Accounts > User profile fields, here are the user profile fields that can be used by the plugin.
    2.- In Site Administration > Plugins > Enrolments > Enrol by user profile fields : the default role should be set and in the "Profile fields to be used in the selector" the user profile fields you want to use with the plugin have to be selected, then save the options.
    3.- In that same screen, leave the Shibboleth Mappings field empty.
    4.- In a test course, go into Course Administration > Users > Enrolment methods and create a new "Enrol by user profile fields method" : optionally give it a name and – that's mandatory – a rule set, it can be one simple rule or a set of rules.

    Users are then enrolled when they next login, or when you click the "Force..." button within the enrolment instance settings.

    Just note that if any user is already enrolled in the course (i.e. by another enrolment method), that user is skipped by the plugin.
  • Picture of Martin Hill
    Wed, Nov 11, 2015, 10:30 AM
    Hi there,

    I set up everything exactly like you described in your manual above. Unfortunately it does not enrol any of my test user. I tested it with Moodle 2.8 and Moodle 2.9.2. If I run cron manually I see the following error

    Running cron for enrol_attributes...
    ... used 3 dbqueries
    ... used 0.018087148666382 seconds
    Scheduled task failed: Legacy cron processing for plugins,Error reading from database

    Any ideas why it won't work?

    Many thanks!
  • Picture of Martin Hill
    Thu, Nov 12, 2015, 1:21 AM
    Ok, I just activated the debugging modus in the plugin. To be a bit more concrete I'm getting the following error:

    stdClass Object
    [rules] => Array
    [0] => stdClass Object
    [param] => Key
    [value] => ABC



    line 95 of /enrol/attributes/edit.php: call to debugging()

    [select] =>
    [where] =>

    line 97 of /enrol/attributes/edit.php: call to debugging()


    line 99 of /enrol/attributes/edit.php: call to debugging()

    Error reading from database

    More information about this error
    Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    [array (
    Error code: dmlreadexception
    Stack trace:

    line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
    line 100 of /enrol/attributes/edit.php: call to mysqli_native_moodle_database->get_records_sql()

    Any ideas?
  • Picture of Sudhanshu Verma
    Mon, Nov 16, 2015, 6:39 PM
    Dear Nicolas,

    I have some custom profile field in moodle and when i am adding this enrolment plugin in moodle and setting rules to automate user enrollment in course and when user matching the criteria could not enrolled and also when I am clicking force enrollment button but still it is not working.
  • Picture of Nicolas Dunand
    Mon, Nov 16, 2015, 10:41 PM
    Hello Sudhanshu,

    This is a known problem that I'm currently fixing. If you're confortable using a pre-release version of the plugin, you can try out the latest release available on GitHub (see the "Source control URL link near the top of this page). If not, I should release an official new version of this plugin within a couple days.
  • Picture of Sudhanshu Verma
    Tue, Nov 17, 2015, 2:08 PM
    Thanks Nicolas for building this great plugin , I will wait for new release.

  • Picture of Nicolas Dunand
    Tue, Nov 17, 2015, 8:45 PM
    Dear all,

    I've just released a new version of this plugin, which addresses all known problems. It is available immediately, and also officially supports Moodle 3.0.

    Thanks to all who reported bugs, and especially to Martin from Canada and Kathrin from Germany, who wen to great lengths to provide details of their debugging sessions.
  • Picture of Jon Bolton
    Wed, Nov 18, 2015, 10:00 PM
    Superb - works really well, thank you. Would it be possible to show the standard user profile fields (eg. city/town, country) as well as custom profile fields?
  • Picture of Nicolas Dunand
    Wed, Nov 18, 2015, 10:22 PM
    Thanks Jon.

    Yes, I would like to add this in the future. I've added this as a feature request (see ).

    In the meantime if anyone is willing to work on this feature I'd be glad to include it.
  • Picture of Sudhanshu Verma
    Thu, Nov 19, 2015, 2:58 PM
    Dear Nicolas,
    Thankyou Nicolas for releasing this plugin once again and fixing issues. You have done really a goodjob by making this plugin.

    Once again thankyou smile

1 2 3
Please login to post comments