Enrol by user profile fields

Enrolment ::: enrol_attributes
Maintained by Nicolas Dunand
This plugin allows users to be enrolled according to any value stored in their user profile.
Latest release:
1415 sites
557 downloads
132 fans
Current versions available: 6

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.

Screenshots

Screenshot #0

Contributors

Nicolas Dunand (Lead maintainer)
CSE Université de Lausanne: Supporting institution
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • JOSE GUILLERMO ROJAS GARRIDO
    Wed, 13 Apr 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 ?
  • Nicolas Dunand
    Mon, 18 Apr 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.
  • Richard Wallace
    Tue, 26 Apr 2016, 3:34 PM
    Nicolas

    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

    Richard
  • Mohammed Ouazzani
    Tue, 26 Apr 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.
  • Dillon Esterhuizen
    Thu, 5 May 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
    SELECT DISTINCT u.id FROM mdl_user u WHERE
    [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.
  • Nicolas Dunand
    Mon, 9 May 2016, 8:45 PM
    Mohammed,

    You have to add an instance of this enrolment plugin to a course to use it. See for instance https://docs.moodle.org/30/en/Enrolment_methods#Managing_enrolment_methods
  • Nicolas Dunand
    Mon, 9 May 2016, 8:48 PM
    Dillon,

    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 = ...").
  • Dillon Esterhuizen
    Mon, 9 May 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 u.id 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.
  • Nicolas Dunand
    Mon, 9 May 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?
  • Mustafa A.
    Wed, 11 May 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.
  • Peter Ward
    Mon, 20 June 2016, 6:23 PM
    Hi Nicolas,

    I've installed your plugin in moodle version 3.0.
    Setup follows your instruction i.e. plugin activated, enrolment method applied to course, custom profile field created.
    When I setup the enrolment method I can see the profile field, and then select the course group that I want to enrol the users into.
    I have two issues.
    1. A student that has the correct text in the 'text entry' profile field, does not get enroled.
    2. When I have multiple profile fields created and then add additional enrolment methods to the same course, the drop down in the plugin only shows a single profile field to select from, rather than allowing me to select a different profile field for my second enrolment method.

    Have I missed something?

    Cheers.
  • Peter Ward
    Tue, 21 June 2016, 8:33 PM
    For those following this thread.

    2. When I have multiple profile fields created and then add additional enrolment methods to the same course, the drop down in the plugin only shows a single profile field to select from, rather than allowing me to select a different profile field for my second enrolment method.

    So you need to select all of the fields you want to use in the plugin configuration, and then all are displayed in dropdown.

  • Peter Ward
    Tue, 21 June 2016, 10:21 PM
    For those following this thread.

    1. A student that has the correct text in the 'text entry' profile field, does not get enroled.

    I noticed that the text editor I was using was wrapping my profile field entry like this in the database

    course1

    This lead to a failure to find the entry and therefore enrol the user.
    When using the plain text editor, or removing the characters from the entry, ( i.e. use 'course1' ) the users were enroled.

    Nice plugin though. Thanks Nicolas.
  • Peter Ward
    Tue, 21 June 2016, 10:51 PM
    Hi Nicolas. Hopefully my last question. Is there a cron job that runs in order to perform the enrolements of your plugin?
    Cheers.
  • Joao Pedro Barros
    Wed, 22 June 2016, 4:30 AM
    When it will support Moodle 3.1?
Please login to post comments