Add a condition in user enrol module

Add a condition in user enrol module

by H B -
Number of replies: 2

We have courses that are used by different schools. When a teacher needs to assign a role to a student for a specific course,  Moodle shows all the users. We only want to show the users from the same school (using field institution).

To show only the users when calling course settings/users/enrolling users it shows the users from a certain institution. I changed that into ../enrol/locallib.php into the function get_total_users(). I added a condition

.. AND u.institution=$spec_instution..

But then when you click on the button enrol users,  a form is showed with ALL the users. My question is:

Where or in which file/function I can add this condition? I haven't been able to find it after 4 hours of searching .

We are using latest moodle 2.3.2.

Attachment enrol.gif
Average of ratings: -
In reply to H B

Re: Add a condition in user enrol module

by Nathan Robbins -

Hi Hellen,

Have you taken a look at the code in ...\enrol\manual\locallib.php? It overrides some of the functions in ...\enrol\locallib.php

If you haven't already, you could take a look at using cohorts for enrolment.

In reply to Nathan Robbins

Re: Add a condition in user enrol module

by H B -

I found it. the 2 functions that needed some adjustments were

get_users() and get_potential_users(). Both functions in locallib.php