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 Nicolas Dunand
    Sun, Feb 14, 2016, 11:55 PM

    Once, installed, you need to activate this plugin by going to Site administration > Plugins > Enrolments and activate this plugin from the table displaying all enrolment plugins available in your Moodle.

    Then, you need to make sure the plugin itself is configured properly.
  • Picture of Franky Just
    Sat, Feb 27, 2016, 3:43 PM

    I've first changed the mdl table prefix issue. But plugin isn't working, not under the role menu, and not under text option or whatever. Moodle 3.0.2 installed.
  • Picture of Nicolas Dunand
    Sat, Feb 27, 2016, 6:42 PM
    Hi Franky,

    Did you set the plugin's settings in "Site Administration > Plugins > Enrolments > Enrol by user profile fields" ? Can you tell me in particular what you've set the "Profile fields to be used in the selector" field to?
  • Picture of Richard Wallace
    Wed, Mar 2, 2016, 3:03 PM
    I have the same problem, I ahve activated it, and set the role to student, but when I go into any course, under enrolment methods, I do not see it at all
  • Picture of Nicolas Dunand
    Wed, Mar 2, 2016, 3:40 PM
    Hi Richard,

    See my comment to Franky above. Setting the role only does not activate the plugin, what have you set the "Profile fields to be used in the selector" field to?
    Wed, Apr 13, 2016, 11:51 PM
    I'am using LDAP with Moodle 3.0 but I can't see user fields like "department" at the enroll Enrolment methods. I only see the USER PROFILE FIELDS that i added. What i miss yo do ?
  • Picture of Nicolas Dunand
    Mon, Apr 18, 2016, 7:32 PM
    Hi José,
    This plugin (for now) only allows to use extra profile fields, not core profile fields. Core fields are all Moodle 'normal' user's profile fields (such as username, first name, phone, department, etc.), whereas extra profile fields are any extra profile fields you define yourself. So if your LDAP plugin can use those extra fields you're good.
  • Picture of Richard Wallace
    Tue, Apr 26, 2016, 3:34 PM

    Sorry you are quite right, admins need to

    ADD a "User profile field" under site admin, users, as well as

    ADD an option in this "User profile field"

    for the plugin to show in Moodle courses at all.

    Once I had done this, it appears in the course. I will continue to play with this, but looks great Nicolas, great work, thanks

  • Picture of Mohammed Ouazzani
    Tue, Apr 26, 2016, 6:25 PM
    Hi Richard,

    I follow the instructions and nothing appears in the course. Any idea ?
    The plugin is activated, i add "User profile field" and in the plugin options i select the profile field created. But nothing is happenning after.
  • Picture of Dillon Esterhuizen
    Thu, May 5, 2016, 12:55 AM
    Hi Nicolas

    I am using Moodle 3.0.1 and as previous comments have stated, I too am having the "Error reading from database" error along with the following debug message when I go into my course>users>enrollment methods>instance name:

    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 103 of /enrol/attributes/edit.php: call to mysqli_native_moodle_database->get_records_sql()

    Along with:

    Exception encountered in event observer 'enrol_attributes_plugin::process_login': Error reading from database
    line 1080 of /lib/dml/msqli_native_moodle_database.php: call to moodle_database->query_end()
    line 291 of /enrol/attributes/lib.php: call to mysqli_native_moodle_database->get_records_sql()
    line 218 of /enrol/attributes/lib.php: call to enrol_attributes_plugin::process_enrolments()
    line ? of unknownfile: call to enrol_attributes_plugin::process_login()
    line 155 of /lib/classes/event/manager.php: call to call_user_func()
    line 75 of /lib/classes/event/manager.php: call to core\event\manager::process_buffers()
    line 804 of /lib/classes/event/base.php: call to core\event'manager::dispatch()
    line 4309 of /lib/moodlelib.php: call to core\event\base->trigger()
    line 185 of /login/index.php: call to complete_user_login()

    Please advise as to why this could be happening and what I could do to fix it.

    Thank you so much for your time.
  • Picture of Nicolas Dunand
    Mon, May 9, 2016, 8:45 PM

    You have to add an instance of this enrolment plugin to a course to use it. See for instance
  • Picture of Nicolas Dunand
    Mon, May 9, 2016, 8:48 PM

    Can you make sure to turn debugging display on, the go and display the faulty enrolment instance, and report back with the debugging text displayed beneath the form (the debugging text should begin with "customtext1 = ...").
  • Picture of Dillon Esterhuizen
    Mon, May 9, 2016, 10:37 PM
    Hi Nicolas

    This is the debugging message:

    customtext1= stdClass Object ( [rules] => Array ( [0] => stdClass Object ( [param] => Job [value] => Personal Trainer ) ) )
    line 95 of /enrol/attributes/edit.php: call to debugging()
    fieldsandrules= Array ( [customuserfields] => Array ( [1] => job [8] => clubname [9] => hspcanumber ) [rules] => Array ( [0] => stdClass Object ( [param] => Job [value] => Personal Trainer ) ) )
    line 97 of /enrol/attributes/edit.php: call to debugging()
    arraysql= Array ( [select] => [where] => )
    line 99 of /enrol/attributes/edit.php: call to debugging()
    sqlquery= SELECT DISTINCT FROM mdl_user u WHERE
    line 102 of /enrol/attributes/edit.php: call to debugging()

    For some context. The custom profile field has the shortname "job" and the fullname "Job Description". One of the Job Descriptions you can select from the dropdown is "Personal Trainer". The other two fields (i.e. 3 in total) are Clubname and Hspcanumber. Job Description and Clubname are compulsory fields and hspcanumber is not, however in the settings for your plugin, I specifically selected "Student" as the role and "Job Description" as the field.
  • Picture of Nicolas Dunand
    Mon, May 9, 2016, 11:35 PM
    It looks lime there would be a bug in my code: it doesn't like "Job" capitalized differently – once "job" and the other time "Job". Could you check this and possible change either so that they match and see if it resolves it?
  • Picture of Mustafa A.
    Wed, May 11, 2016, 7:54 PM
    A good feature of this plugin would be supporting more operators, like < (smaller then), > (greater then), like %xxx%.

    For example: I get employee no from Active Directory. I'd like to enroll all users whose employee no is greater then some value to a course.
1 2 3 4 5
Please login to post comments