Enrolment: Enrol by user profile fields

Maintained by Picture of Nicolas DunandNicolas Dunand
This plugin allows users to be enrolled according to any value stored in their user profile.
1213 sites
92 fans
Current versions available: 4

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)
Picture of RISET Université de Lausanne
RISET Université de Lausanne: Supporting institution
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Noortje Engels
    Thu, Jun 4, 2020, 5:29 PM
    Hi Nicolas,
    I've installed the correct build for my moodle environment (2018092300). But when I add them as an enrollment method the plugin doesn't show itself very good. I cannot see the three buttons (add, brackets, delete), i only see some crooked text which is not readable.
    My moodle version is: Moodle 3.2+ (Build: 20161222) and I've installed enrol_attributes_moodle35_2018092300. I've tried to install the 2000 version but it gives the same result.
    I really haven't got a clue where to look for the solution. I hope you can help smile.

    Thanks in advance.
    Kind regards,
  • Picture of Nicolas Dunand
    Thu, Jun 4, 2020, 5:32 PM
    Hi Noortje,
    This plugin is know to have some display issues with some third-party themes. Could you mention which theme is active in your Moodle installation ?
    Moreover, I have to point out that even if this plugin functionally supports Moodle 3.2, this Moodle version is long out
    of date.
  • Picture of Nicolas Dunand
    Thu, Jun 4, 2020, 5:33 PM

    Sorry, your comment espaced my attention. This plugin doest not allow individual user deletion (unenrollment), as presumably the user would be enrolled again after a while if his profile fields match the enrollment rule.
  • Picture of Israel Pelayo
    Sat, Aug 15, 2020, 1:23 AM
    Excellent plugin, it has helped me a lot. Thank you so much for everything. Would it be possible to integrate the functions of start date and end date to carry out the enrollment? It would be great if dates could be controlled. Thank you very much.
  • Picture of Nicolas Dunand
    Sat, Aug 15, 2020, 3:45 AM
    Thanks Israel for your feedback. Indeed this could be a good improvement. I'm not making any promises, but please suggest this as a new issue on GitHub (see "Source control URL" link above), so we can discuss this in detail.
  • Picture of Israel Pelayo
    Sun, Aug 16, 2020, 11:47 AM
    Thank you very much Nicolas Dunant. I will put the suggest on GitHub right now. Have a nice day
  • Picture of Jeff Yonker
    Wed, Sep 2, 2020, 10:00 PM
    Are you still supporting this?
    If so, I am running moodle 3.5 and have tried installing all 3 versions that say they are verified for my version. All 3 install and configure correctly, however when I try to add the method to a course I'm getting an error:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator at webmaster@disasterrelieftraining.com to inform them of the time this error occurred, and the actions you performed just before this error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

    Server log only shows this: [01-Sep-2020 19:04:03 America/Chicago] PHP Notice: Undefined index: State in /home/onlinedi/public_html/lib/navigationlib.php on line 1898

  • Picture of Nicolas Dunand
    Wed, Sep 2, 2020, 10:59 PM
    Hello Jeff,

    Yes this is still functional and fully supported in supported Moodle versions. To track down the problem, I would advise to make your Moodle display debug messages that could provide you a lead on the cause of the error. The "php notice" log entry is not related to that "Internal Server error" that you see.

  • Picture of Jeff Yonker
    Thu, Sep 3, 2020, 12:45 AM
    Thanks Nicolas.
    I have all the debugging already turned on. Im not sure where I should look for the debugging messages.
    When I try to add that enrollment method it immediately goes to a generic white screen with that error - no debug info.
  • Picture of Jeff Yonker
    Thu, Sep 3, 2020, 12:59 AM
    Now I also have a dev site and when I add the enrol method it seems to work but when I edit it , the settings don't stick and I get this error:

    Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 1273 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
    line 120 of /enrol/attributes/edit.php: call to mysqli_native_moodle_database->get_records_sql()
  • Picture of Nicolas Dunand
    Thu, Sep 3, 2020, 2:59 PM
    Jeff, it look like the method you are adding just contains no parameters, hence the empty Array() in the debugging message. Please post in the bug tracker if you want this issue followed properly – it allows for more direct communication and posting of screenshots etc. Thanks!
  • Picture of Scott Burnett
    Sat, Sep 19, 2020, 2:27 AM
    First of all, I love this plugin, this is going to make a big difference in my agency for enrolling my employees.

    I am going to give a little background to help with making these questions make more sense.
    We are a State Public Health agency. We have both internal and external users on our system. In some of the courses we want our employees only, in others external only, and other both.

    This brings up 2 questions that I have.
    1: I saw on the Github entry for the plugin someone requested a NOT function to go along with the AND/OR function, is there movement on that? I would like to see this as well.
    2: I am going to use an example of email addresses. In the system, our employees have a @mt.gov address where external users do not. Is there a way to select just the mt.gov addresses. For example *@mt.gov. Where it would only select those with the email address. Or if using the employee ID number, all profiles that have an employee id number in the field but exclude the ones who do not (which would be external users).

  • Aaron Cauchi
    Tue, Nov 24, 2020, 4:13 AM
    I created a custom profile field which is registration date. I want to use this profile field to enrol users to a specific course but they must be already registered for more than two years from present month and year (today's date) to be able to do course. Can you assist as what to language or formula to use? I tried using Now()) > 24 and also TODAY() - 730 > date but to no success.

    Appreciate any help
  • Picture of Niall Sheehan
    Fri, Feb 5, 2021, 10:48 PM
    I've run into an issue with the Enroll by profile field. While testing the plugin, I found an issue with the Auto unenroll when attribute expires. Once my test user was unenrolled from the test course used for testing this enrollment method, no matter what I've tried, he can not be enrolled in any course using Enroll by profile field.

    Course: Test Course #1
    Custom Profile Fields: Field 1 (first, second, third), Field 2 (1, 2, 3)
    Enrollment Method: Enroll by profile field, Field 1 = first
    User: User One
    Profile Fields: Field 1 = First, Field 2 = 2

    User enrolled.
    Changed Field 1 to second
    User unenrolled
    Changed Field 1 to First
    User not added to course.
    Purged all enrollments, ran tasks, cron job, forced enrollments, user not enrolled.
    Created New Test Course
    Configured the Enroll by profile field the same as for Test Course 1
    Users enrolled, but not Test User 1.
    Changed enrollment rule to use Field 2 = 2, users enrolled, but not Test User 1.

    I can verify that the user profile fields contain the expected values, that users can be enrolled and unenrolled, but not re-enrolled or enrolled in other course once a attribute changes and the user is automatically unenrolled.

    Any ideas? I'm at a loss.
  • Picture of Nicolas Dunand
    Sat, Feb 6, 2021, 12:52 AM
    Hello Niall,

    Thanks for reporting this, this is not as it should work. Could you please post this in the bug tracker ? see link on this page. This way I can keep track on things that need looking into or be corrected.

Please login to post comments