Moodle plugins directory: Enrol by user profile fields | Moodle.org
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.
Useful links
Contributors
Nicolas Dunand (Lead maintainer)
CSE Université de Lausanne: Supporting institution
Please login to view contributors details and/or to contact them
Thanks for a great plugin.
I am having trouble working out why I am not able to enrol based on a user profile I have set up.
I have created a custom profile field and successfully updated records of 20 users with a particular value I want to use for enrolment.
I can find these users by filtering on the field and value in Browse users in site admin.
When I go to a course, I can select the enrolment method and it brings up the correct field and I can enter the value.
There is no error message but in the enrolment data box it shows 0 users have been enrolled with this method.
I am logged in as admin so permissions should not be an issue.
I was able to enrol a cohort, so it should not be to do with course or user expiry (I am working on a dev site).
Any suggestions?
Many thanks
Lynn
Thanks for your message. What happens if, after having saved your rule, you display it and click the "Force enrolments" button?
I installed moodle 3.3 version using mysql 5.6.36 and I have install this plugin.
I have added 2 other fields (named field1 & fields) in user profile. However, when I selected the "Enrol by user profile" (in Users > Enrolment Methods) , the error showed as below
customtext1=line 112 of /enrol/attributes/edit.php: call to debugging()
Notice: Trying to get property of non-object in /var/www/html/moodle/enrol/attributes/lib.php on line 128
fieldsandrules= Array ( [customuserfields] => Array ( [1] => field1 [2] => field2 ) [rules] => )
line 114 of /enrol/attributes/edit.php: call to debugging()
Warning: Invalid argument supplied for foreach() in /var/www/html/moodle/enrol/attributes/lib.php on line 149
arraysql= Array ( [select] => [where] => [params] => Array )
line 116 of /enrol/attributes/edit.php: call to debugging()
sqlquery= SELECT DISTINCT u.id FROM {user} u WHERE
line 119 of /enrol/attributes/edit.php: call to debugging()
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 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 1175 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()
Hope anyone can help. Thanks in advance.
Thanks for reporting this problem. First, can you confirm you have the latest version of this plugin ?
Then, does this error appear as you're trying to create a new enrolment method ? Or when displaying an existing one ?
Thanks for your prompt reply.
My installed plugin version is 2017050100. And the error appears when displaying an existing one.
This looks like what would happen is the rule set is completely empty (see "customtext1=" at the beginning of your debugging messages). There should be something there, not just nothing. Have you set up a rule ? If you reload the page with JavaScript turned off, you should see the code (JSON) for the rule, e.g. "{"rules":[{"param":"paramname","value":"somevalue"}]}". is that the case?
I've installed your -really very useful, thank you very much indeed!- plugin on Moodle 3.2.1+ (Build: 20170223) and got it working on a development site here at La Sapienza University in Rome.
Nevertheless at the bottom of the edit page (/enrol/attributes/edit.php?courseid=XYZ&id=ZX) I read:
customtext1= stdClass Object ( [rules] => Array ( [0] => stdClass Object ( [param] => CODCDL [value] => 14493 ) [1] => stdClass Object ( [param] => CODCDL [value] => 14494 [cond_op] => or ) ) )
line 112 of /enrol/attributes/edit.php: call to debugging()
fieldsandrules= Array ( [customuserfields] => Array ( [2] => CODCDL ) [rules] => Array ( [0] => stdClass Object ( [param] => CODCDL [value] => 14493 ) [1] => stdClass Object ( [param] => CODCDL [value] => 14494 [cond_op] => or ) ) )
line 114 of /enrol/attributes/edit.php: call to debugging()
arraysql= Array ( [select] => RIGHT JOIN {user_info_data} d1 ON d1.userid = u.id AND d1.fieldid = 2 RIGHT JOIN {user_info_data} d2 ON d2.userid = u.id AND d2.fieldid = 2 [where] => (d1.data = ? OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\') OR (d2.data = ? OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\') [params] => Array ( [0] => 14493 [1] => %;14493 [2] => 14493;% [3] => %;14493;% [4] => 14494 [5] => %;14494 [6] => 14494;% [7] => %;14494;% ) )
line 116 of /enrol/attributes/edit.php: call to debugging()
sqlquery= SELECT DISTINCT u.id FROM {user} u RIGHT JOIN {user_info_data} d1 ON d1.userid = u.id AND d1.fieldid = 2 RIGHT JOIN {user_info_data} d2 ON d2.userid = u.id AND d2.fieldid = 2 WHERE (d1.data = ? OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\') OR (d2.data = ? OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\')
line 119 of /enrol/attributes/edit.php: call to debugging()
countusers= 0
line 121 of /enrol/attributes/edit.php: call to debugging()
If I disable Javascript I see in the rule box:
{"rules":[{"param":"CODCDL","value":"14493"},{"param":"CODCDL","value":"14494","cond_op":"or"}]}
As I miss the meaning and wonder if it is dangerous, any suggestion is really appreciated.
Thank you for your time.
Have a wonderful day.
Ciao,
Francesco
Please help me!
I´m testing your plugin and i´m having a problem that I cound not revolve.
When a user signs up (using no authentication method), i cannot access the course that I have previously configure for the custom field. I have to log off and log on an when I log in again, I can access to the course. If I click "force enrollment" while the user is logging in, refresh the page and it´s works. But, I need that after the user "sign up", the user has access to the course.
Do you know how to resolve it?
Thanks!
I'm Francesco...I've a Moodle 3.1.6...I've installed the plugin version 2.4.2.
The installation has been successful.
The problem is that the "Enrol by user profile fields" method does not appear in Enrolment Methods, even if it is enabled between plugins.
Do you know how to resolve it?
Thanks!