Enrolment: Enrol by user profile fields

enrol_attributes
Maintained by Picture of Nicolas Dunand Nicolas Dunand
This plugin allows users to be enrolled according to any value stored in their user profile.
600 sites
551 downloads
44 fans

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

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 Sofia Rehan Ramli
    Wed, 21 Feb 2018, 6:19 PM
    Hi Nicolas,

    Thank you for your reply. Just wondering, is it possible to have that the criteria matches any word found in the user profile field, instead of must be exactly the same as the profile field? For example I want the user profile field to contain the word Engineering, but it can be any type of Engineering.
  • Picture of Mantas Šedys
    Thu, 8 Mar 2018, 3:14 AM
    Hi,
    after two days investigation I need your help guys.
    My enrolls by profile fields stopped working and I can't find what is wrong. It's not starting automatically, but if I press "force enrolment now" - everything run smoothly. Any ideas?
    Moodle - 3.3 / Plugin - (2017050100)
  • Ricardo Caiado
    Sat, 17 Mar 2018, 11:11 PM
    Hi,

    Any update to Moodle 3.4?

    Ricardo
  • Picture of Nicolas Dunand
    Mon, 19 Mar 2018, 3:13 PM
    Hi Ricardo,

    This plugin should work on Moodle 3.4.
  • Picture of Beto de Oliveira
    Tue, 20 Mar 2018, 11:01 PM
    Hi,

    I have the same question as Sofia:

    "Just wondering, is it possible to have that the criteria matches any word found in the user profile field, instead of must be exactly the same as the profile field? For example I want the user profile field to contain the word Engineering, but it can be any type of Engineering."

    Thank you.
  • Picture of Nicolas Dunand
    Tue, 20 Mar 2018, 11:20 PM
    Hi Beto,

    The login of field content comparison is in the lib.php file, more precisely see https://github.com/ndunand/moodle-enrol_attributes/blob/master/lib.php#L177

    You could change this to affect the behaviour to match your intended purpose.
  • Picture of shivshankar kesha
    Wed, 4 Apr 2018, 11:31 PM
    Hi Mantas Šedys,

    I am facing same issue in 3.1 did you get any solutions for this, please suggest if you fixed.
    Bug: My enrolls by profile fields not working , It's not starting automatically, but if I press "force enrollment now" - everything run smoothly. Any ideas?
  • Picture of Matias Kapoble
    Tue, 10 Apr 2018, 12:05 AM
    Hi Nicolas Dunand,

    I want to know what happend if i change a user profile. Does the plugin unenrol the user? That would be very useful.

    Or if there is a way to manually unenrol the user.

    Thanks,
  • Picture of Nicolas Dunand
    Thu, 19 Apr 2018, 2:52 PM
    Hi Matias,

    Yes, if you check the "Unenrol after attributes expiration" box in the enrolment method, then the person whose attributes no longer match the rule would be unenrolled after their next login.
  • Picture of Brian Kenwell
    Thu, 26 Apr 2018, 5:54 PM
    Hi Mantas Šedys & shivshankar kesha,

    I too was facing the same issue -- all of a sudden new courses we added to Moodle were not working with enrol_attributes -- but all of our existing courses remained working as expected. We're using our own SAML idp that does a Drupal => Moodle login, so between simpleSAMLphp, Drupal & Moodle, a lot of debugging took place before finally figuring out the issue (which was so simple it was a bit frustrating).

    In enrol_attributes's process_enrolments() function -- https://github.com/ndunand/moodle-enrol_attributes/blob/74621611ff92f55d178a7926bc592b2d5bc5701a/lib.php#L310 it breaks out of the user enrollment part of the function if there are any courses that enrol_attributes is active on, but not properly configured (User profile fields rules is empty). So in my case, we had a bunch of courses setup and functioning properly, then a course was added with this enrollment method enabled, but the rule didn't save properly. We added a bunch of new courses so it wasn't immediately obvious one was missing a rule.

    Nicolas Dunand - I'm writing this after many hours of debugging, so I'm probably not thinking clearly, but I'm curious of the reasoning for writing that chunk of code the way you did?
    I also discovered the attributes/edit.php form is broken (at least when using the Edwiser RemUI theme https://edwiser.org/remui). When we press the "Save changes" button nothing is saved - both on initial setup and when editing an existing instance. We have to press the return key while the cursor is in the text box for the changes to be saved. This could be 100% a theme specific issue, but figured I should mention it incase others are using the same theme.

    I'm a big fan of your plugin! It's super easy to setup and incredibly useful -- especially for SAML setups (please don't take any of this as me not appreciating all your work -- I very much do).
    I just spent many hours debugging all this so hopefully other users experiencing the same issue won't have to.
  • Picture of Nicolas Dunand
    Thu, 26 Apr 2018, 7:51 PM
    Hi Brian,

    Thanks a lot for your report. I really appreciate you sharing your discovery and taking the time to explain it here.

    I looks like you might have found the issue plaguing so many here. I've been looking at this and I'm thinking that this "break 2" and the previous "break" should act in the same way (the purpose is to try and eliminate misconfigured rules, or rules using attributes not listed by the plugin 'profilefields' setting.

    I can't figure why both breaks should behave differently. Another case against badly documented code. Off the top of my head, these should both be "continue 2" – to break off the foreach ($enrol_attributes_records ...) loop. Is that how you fixed it?
  • Picture of Brian Kenwell
    Fri, 27 Apr 2018, 2:51 AM
    Hi Nicolas,

    I try not to hack other peoples code unless it's the only option, so in my case I simply corrected the course that had enrol_attributes enabled, but the rule left empty. Justing putting any random value in the "User profile fields rules" field fixed the issue. I should also specify that the edit form is only broken (at least in RemUI theme) if the rules is a very simple rule (one field, one value) which almost all of our rules are. If a modifier is added (this field and/or that field, or this value and/or that value) the save button does work.

    Because I found the cause of the issue, I didn't continue to troubleshoot what those variables look like or how much different they might be for simple vs complex rules, but I think you're headed in the right direction. Maybe use count() or something to figure out if this is a simple or complex rule and then determine if continue/break or continue 2 / break 2 is needed. In our database we had a course in the enrol table with a record for attributes and status set to 0 but the customtext1 field was blank.
  • Picture of Nicolas Dunand
    Wed, 2 May 2018, 1:09 PM
    Hi Brian,

    Thanks for your feedback and further explanation. I'll include a fix for this in the upcoming release.
  • Picture of safiyullah mohamed
    Thu, 3 May 2018, 12:05 AM
    I have installed and enabled the plugin properly. When i go and check on Users - > Entrollmethods Methods, Respective plugin not listed in "Add method drop down list". but i can see other enrollment plugins like Self, Auto, Manage entrollment ect.

    Any help would be appreciated.
  • Picture of Nicolas Dunand
    Tue, 8 May 2018, 2:34 PM
    safiyullah mohamed, make sure you have set up the plugin properly, i.e. in the plugin preferences read all settings descriptions in Site Adminitration > Plugins > Enrolment > Enrol by user profile fields.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Please login to post comments