Enrol by user profile fields

Maintained by Nicolas Dunand
This plugin allows users to be enrolled according to any value stored in their user profile.
Price option: Free

Supports Moodle 2.1-5.0 See all versions
Latest release: 1 year ago
Installations: 1874
Downloads (last 90 days): 314

Frankenstyle name: enrol_attributes
Enrolment

Comments

Product ratings and reviews are coming to Moodle Marketplace. Until then, existing comments remain available to read, but new posts have been disabled.

I want to teach those who are unequal.
Please help me!
I did all the chances and possibilities to have this plugin fixed on my system. But I never had the result to get this plugin work properly. I did reinstall the Enrolment Plugin on my system, have the other enrolment plugins reviewed, and eventually put this Plugin on the top of the Enrollment Stack.
Ciao Nicolas, so I guess I don't have to worry about it... thanks again and Grazie for your excellent work.
Ciao Francesco and thanks for your concern. This only displays if your site has debugging activated (and on display) OR if you are an administrator.
Hi Nicolas,
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
Hi Ray,
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?
Hi Nicolas,
Thanks for your prompt reply.
My installed plugin version is 2017050100. And the error appears when displaying an existing one.
HI Ray,
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 ?
Hi, First of all, thanks for sharing this plugin.
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 egg )
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.
Hi Lynn,
Thanks for your message. What happens if, after having saved your rule, you display it and click the "Force enrolments" button?
Hi
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
Same here Nicolas, I'd like to implement that function from your basis but ain't got no time... Hope that someone will continue your work. Anyway, again, great job
Hi Dario,
Thanks for your feedback and suggestion. Indeed it would be very useful – and so would be other operators (greater than, etc.) – but I have really not time at all to do that in the foreseeable future.
If somebody was willing to program it I'd be very happy to integrate it so that everybody could use.
Hi Nicolas, first of all thank you for this useful plugin. Just a suggestion: it would be great to have the chance to choose between "the field is euqal to" and "the fild contains". Don't know if it's feasible but it could be helpful.
Thank you again for your contribution.
Kate, yes that's what I thought. I can't come up with any more ideas but PM me if you want me to further investigate this.