Moodle Plugins directory: Cohort role synchronization | Moodle.org
Cohort role synchronization
Moodle Cohorts are a great tool for creating site-wide groups of users, and using these groups to enrol users en-masse into courses. This plugin extends the functionality of cohorts by allowing them to be automatically assigned to system-level roles.
This is especially useful for local customizations, i.e. you want your Staff Users cohort to be enrolled into all staff related courses, but also assign them to a system role that grants them extra permissions across the site. By listening for relevant events, any amendments made to configured cohorts will automatically be reflected in the appropriate roles.
After installing the plugin, linking a cohort to a role is as simple as selecting each from a dropdown menu and pressing Save changes:
See the project readme file for the most up to date instructions.
Supports Moodle version 4.1 onwards (up to and including 4.5).
The latest plugin release is 4.5 (8 October 2024):
- Support for Moodle 4.5
you might be interested that we created a plugin which provides a mapping from custom user profile fields to cohorts. It is published on https://github.com/moodleuulm/moodle-local_profilecohort and currently waiting for approval in the plugins repo.
I have recommended your plugin in our plugin's README as a solution for mapping from custom user profile fields to system roles and we are using this combination in production.
Thanks for your work!
Alex
Awesome plugin, just what we need for making our moodle site a little bit easier to maintain. It's working on our 3.2 test site right now but we're planning to push our site to 3.3 soon too and we're wondering if there are any known issues with it on 3.3 as it isn't officially compatible according to this page.
Cheers,
Rob
I would like to give the manager-role the capability to perform this plugin.
In my site the function is only available to the admin.
How can the capabilities be set?
Any updates to Moodle 3.5?
Ricardo
That would be really great!
Thanks for a great plugin
Is there any chance you could extend this plugin so that cohorts could be assigned roles in categories?
But from that moment if I add a new user to the cohort that new user is not added to the system role anymore. I am using "Profile field based cohort membership" to add the users to the cohort.
I just wanted to check if the above behaviour is expected or if there is something wrong in my tests?
Execute scheduled task: Sincronizar asignaciones de roles de cohorte (tool_cohortroles\task\cohort_role_sync)
... started 09:29:02. Current memory use 32.9MB.
Sync cohort roles...
Added 0
Removed 0
... used 3 dbqueries
... used 0.0045390129089355 seconds
Scheduled task complete: Sincronizar asignaciones de roles de cohorte (tool_cohortroles\task\cohort_role_sync)
Any feedback in the compatibility of local_cohortrole with the plugin "Profile field based cohort membership" would be appreciated?
I need to map a global group to a specific system role in individual course areas.
The plugin currently only works system-wide.
Are there any plans to further develop the plugin in this direction?
Greetings Stephan
I have the role 'student' assigned to the cohort 'abc' and upon creation, all the existing cohort members became students...success! However when a new user registers and becomes a member of the cohort via profile field based cohort membership, they do not get the role sync to 'student' and the sync cohort roles is running. I'm stumped.
After that, even if I add or delete a user from the cohort, it will not synchronise again?
If this is true, why does it need the scheduled task?
Fortunately I found the solution here:
https://github.com/paulholden/moodle-local_cohortrole/issues/11#issuecomment-2249791430
The key is: "for Dynamic Cohorts is to not enable the 'Bulk processing' option"
Thanks to everyone!