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.
427 sites
29 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.


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
    Tue, 20 Sep 2016, 4:38 PM
    Hi Jürgen,

    Thanks for your feedback – yeah it would be great, I really have to look into this as soon as I have a moment.
  • Picture of Andras Koharek
    Wed, 21 Sep 2016, 12:07 AM
    Hi Nicolas!

    let me join Jürgen's idea, and hope you will have that moment soon smile

  • Picture of Dietmar Grasböck
    Wed, 21 Sep 2016, 2:17 PM
    Hi Nicolas!

    great plugin that saves our trainer some time smile

    It would really be great, if it would work with the standard Moodle profile fields as well wink

    Regards, Dietmar
  • Picture of Blair F.
    Thu, 22 Sep 2016, 4:23 AM
    I agree with Jürgen that it would be great if other fields could be used, as well. In fact, my wish is just slightly more complicated: I would like to be able to use the email domain or subdomain. For example, all of our students emails end in @student.ourschool.com and our employees end in @ourschool.com. I'd love to be able to auto-enrol students and teachers. We've got a custom "usertype" field (for some reason unknown to me), but I don't know how to populate it automatically, so it's not useful with this plugin, unless we manually enter the data.
  • Picture of Dietmar Grasböck
    Fri, 23 Sep 2016, 5:49 PM
    Hello Nicolas,

    you mentioned, that the enrolment happens in two ways:
    - enrol as user logs into Moodle (if it matches, obviously)
    - enrol during cron job, every 6 hours

    I have the problem, that my users cannot login anymore, when i define many (more than 20) criterias with the "OR" operator, to enrol in one course. It seems that during the login process some SQL querries run in infinite loop preventing the login going on. Only when the Admin purges the SQL queries users can continue to login.

    We use Moodle 2.9.2+ with 4.800 Users.

    Any ideas?

    As the enrolment triggered by the cron job seems to work without problems, is there a way to exclude the enrol process as user logs into Moodle? Where would I have to make changes?

    Best regards, Dietmar

  • Picture of Nicolas Dunand
    Fri, 23 Sep 2016, 7:30 PM
    Hello Dietmar,

    Thanks for reporting this.

    Indeed it seems that you are hitting performance limits – these can arise when the number of users is high (not so much in your case) or the complexity of the rules increase.

    As a first step, you could prevent the execution of the login hook by modifying the code as follows, in the file enrol/attributes/lib.php . After the function declaration `public static function process_login`, on the next line, simply add a line that contains `return true;` (without the quotes).

    I hope this helps, le me know!

  • Picture of Zoltán Szalay
    Mon, 28 Nov 2016, 8:27 PM
    Dear Colleagues!

    I am using shibboleth authentication. I have created a custom user profile field named 'courses' and I map the shibboleth attribute 'niifEduPersonCourse' to it.
    I receive the courses IDs separated by semicolons from the authentication server. (e.g.: niifEduPersonCourse: BMEGT20M002;BMEVIMH9O02;BMETE11MX01;)
    Unfortunately, only the first course ID is mapped correctly and the others are lost. Therefore, I cannot use correctly the 'enroll by user profile fields module' (only for the first course) .
    Anyone else meet this problem as well?
    Could you please help me to resolve this problem? How can I enroll the users automatically to the right courses based on the course IDs received by shibboleth?

    Thank you in advance for your response and help!

    Best regards,
  • Picture of Nicolas Dunand
    Tue, 29 Nov 2016, 4:24 PM
    Dear Zoltán,

    This plugin was actually initially developed with this exact idea in mind (Shibboleth attributes, and semicolon-separated values). So it should work as you expect.

    To investigate, you would need to turn on debugging (at least temporarily) on your Moodle site, and then display the enrolment method that you're trying to get to work. Below the form should then be displayed some debugging information, containing actual SQL queries that should return corresponding users. This could help you narrow down the problem.

    Please do not post sensitive information in public places, but if you're comfortable with it, you can PM me with this additional information, and I'll try to help you out.

    Best regards,
  • Picture of Nathan Stevenson
    Wed, 21 Dec 2016, 3:01 AM
    Trying to setup this plugin and work with it:

    It's showing as installed, and when I manage plugins I can see it. However when I go to a course instance and go to enrollment methods, it doesn't present itself as an option to select and add to the course. Help? (Moodle 3.1 instance)
  • Picture of Nicolas Dunand
    Wed, 21 Dec 2016, 4:25 PM
    Dear Nathan,

    Please check the plugin's main settings page. You have to select at lease one item for the "Profile fields to be used in the selector" setting or the plugin won't be enabled.
  • Picture of Nathan Stevenson
    Thu, 22 Dec 2016, 5:50 AM

    We get an option to set Enrol by user profile fields: Default Role (Set to student currently). That's the only option we have Site Admin > Plugins > Enrolments > Enrol by user profile fields
  • Picture of Zoltán Szalay
    Thu, 22 Dec 2016, 5:42 PM
    Dear Nicolas,

    I could try the plugin. If I fill the customized profile field manualy the pluging works properly. So the problem is with the mapping during the shibboleth authentication. As I described before, only the first course ID is mapped. I think there is a little bug in the PHP code handling the semicolons. However, unfortunately I am not a skilled PHP programmer. I have tried to find a forum post or anything else which deal with the problem but I could not find any.
    Could you please help me regarding this issue or suggest someone who can?

    Best regards,
    Zoltán Szalay

  • Picture of Oguzhan Ahiskali
    Thu, 19 Jan 2017, 6:15 PM
    Users who are subsequently added in bulk will be forced to "force the user to assign"..
    Can we provide automatic attendance for a certain period of time as a scheduled task?

  • Picture of Gemma Lesterhuis
    Thu, 26 Jan 2017, 2:54 AM
    Hi Nicolas,

    I am working on Moodle 3.1 with this plugin and I am trying to figure out if it's a cron issue or something else that is causing people not to auto enrol. If I use "force" it works fine. It's just 1 rule that need to be checked.

    You mentioned the plug-in works for auto-enrolment on:
    - enrol as user logs into Moodle (if it matches, obviously)
    - enrol during cron job, every 6 hours

    I have set the plugin with my rule, and forced the cron job, but I don't see the enrollment happening with those who have the profile field checked. I am looking at /admin/tool/task/scheduledtasks.php to see if I can find the "6 hour cron job" so I can check if this is the issue, but can't find it for this plug-in. Is the plug-in running at the same time with a different cron task?

    Thank you Gemma
  • Picture of Nicolas Dunand
    Thu, 26 Jan 2017, 4:44 PM
    Hi Gemma,

    Actually this plugin uses the "legacy" cron system, not the scheduled tasks yet – that's why it's not listed there.

    On the actual rule definition, with debugging turned on in Moodle, you can see the actual query and number of user accounts matched ("coutusers"), which might help you diagnose why your rule is not working.
1 2 3 4 5 6 7 8
Please login to post comments