Thomas Korner
Lead maintainer
Cohort Membership manages cohort memberships via CSV: add users to cohorts, remove them, or sync a user's cohort memberships to an exact target state. UI-based (CSV upload) with dry-run, an HTML report, and CSV download; two CLI entry points are also provided. Why this plugin exists Moodle core has no built-in way to remove users from cohorts via CSV or the UI — this is an open tracker request, MDL-61007, open since 2017. Core's Upload users tool already covers add via cohort columns, and the core_cohort_delete_cohort_members web service covers remove programmatically, but neither has a UI, a dry-run, or a report. This plugin fills that gap and extends it to cover add, remove, and sync in one CSV format, one report, one dry-run. Design principles Never auto-creates cohorts — an unknown cohort is an error row in the report, never a silent new cohort (a deliberate deviation from core's Upload users behaviour, which is a frequent source of duplicate-cohort chaos). Dry-run is the default. All membership changes go exclusively through Moodle's cohort_add_member() / cohort_remove_member() — never a direct database write. A single bad CSV row never aborts the whole run; only file-level problems reject the file before any row is processed. Every CSV row produces exactly one report line. Cohort-sync warning Removing a user from a cohort can trigger an automatic course unenrolment if the cohort feeds an active "Cohort sync" enrolment method — taking grades and group memberships with it. Every removal row in the report is flagged if this applies, so admins can catch it before running in live mode. Compatibility Moodle 4.5 LTS and 5.0–5.2, PHP 8.1–8.4. Verified with the full PHPUnit suite and a live CLI smoke test against each supported Moodle version, on both MariaDB and PostgreSQL. Licensed under GPL v3 or later. Full specification and CSV format examples are in the GitHub repository.