{"id":19591931,"url":"https://github.com/catalyst/moodle-local_cohortauto","last_synced_at":"2026-03-08T16:02:14.033Z","repository":{"id":42428685,"uuid":"200132663","full_name":"catalyst/moodle-local_cohortauto","owner":"catalyst","description":"  Automatically add users into cohorts. (Previously moodle-auth_mcae.)","archived":false,"fork":false,"pushed_at":"2025-02-17T04:20:37.000Z","size":54,"stargazers_count":11,"open_issues_count":11,"forks_count":14,"subscribers_count":37,"default_branch":"MOODLE_402_STABLE","last_synced_at":"2025-04-05T00:41:24.129Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://moodle.org/plugins/local_cohortauto","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catalyst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-01T23:41:15.000Z","updated_at":"2024-09-19T09:18:32.000Z","dependencies_parsed_at":"2024-03-11T05:23:07.233Z","dependency_job_id":"837bf797-8bb6-4d4f-ac2a-3da9b985336a","html_url":"https://github.com/catalyst/moodle-local_cohortauto","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-local_cohortauto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-local_cohortauto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-local_cohortauto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst%2Fmoodle-local_cohortauto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catalyst","download_url":"https://codeload.github.com/catalyst/moodle-local_cohortauto/tar.gz/refs/heads/MOODLE_402_STABLE","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251154632,"owners_count":21544531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T08:32:01.648Z","updated_at":"2026-03-08T16:02:13.781Z","avatar_url":"https://github.com/catalyst.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Auto-cohort local plugin for Moodle 3.5+\n\nThis local plugin automatically adds users into cohorts, with names that\nderived from the users' profile fields.\n\nThis plugin requires Moodle 3.5 or greater (using PHP 7 or greater).\n\nAuto-created cohorts are made in the top-level system context (CONTEXT_SYSTEM).\n\n\n## Migrating cohorts from the `auth_mcae` plugin\n\nThis plugin is derived from, and intended to deprecate, the earlier `auth_mcae`\nplugin by Andrew Kama. See the [auth_mcae plugin repository](https://github.com/danmarsden/moodle-auth_mcae)\nfor more information.\n\nThe two plugins could be installed side-by-side, but the `local_cohortauto`\nplugin can conflict with user update event handling from the earlier plugin,\ncausing multiple cohorts to be created, each managed by its own plugin.\n\nYou can convert older cohorts to be managed by this plugin at:\n`/local/cohortauto/convert.php`\n\nThe MCAE plugin can be uninstalled before conversion takes place, but be\nsure to make a copy of any settings from the older plugin that you wish to keep.\n\n## Installation\n\n* Download the archive and install the files into: `your_moodle/local/cohortauto`\n* Ensure files have been copied in with the same permissions as the rest of your\n  Moodle.\n* Visit the *Site administration - Notifications* page and follow the instructions\n\n## Configuration and operation\nVisit the *Site administration - Users - Accounts - Cohort role synchronization * page\n\nMoodle uses the [Mustache](https://docs.moodle.org/dev/Templates) templating\nlanguage for rendering data into HTML for presentation. This plugin reuses that\nfunctionality, by turning values from a user's profile into cohort names. This\nallows a site administrator to make rules for the automatic creation of cohorts\nbased on user properties.\n\nThe process of creating automatic cohorts or adding users to them happens when\neach user profile is created or updated, or when command line scripts are run.\n(`cli/sync_user.php` for individuals, and `cli_sync_users.php` to sync across\nall users).\n\n\n### Main template (`mainrule_fld`)\nOne value per line.\n\nIn the template you may use any characters (except '{' and '}') and profile\nfield values. To insert a profile field value, use a `{{ field_name }}` tag.\n\nBy default, Moodle provides the following profile fields:\n\n*{{ id }}, {{ auth }}, {{ confirmed }}, {{ policyagreed }}, {{ deleted }},\n{{ suspended }}, {{ mnethostid }}, {{ username }}, {{ idnumber }},\n{{ firstname }}, {{ lastname }}, {{ email.full }}, {{ email.username }},\n{{ email.domain }}, {{ email.rootdomain }}, {{ emailstop }}, {{ icq }},\n{{ skype }}, {{ yahoo }}, {{ aim }}, {{ msn }}, {{ phone1 }}, {{ phone2 }},\n{{ institution }}, {{ department }}, {{ address }}, {{ city }}, {{ country }},\n{{ lang }}, {{ calendartype }}, {{ theme }}, {{ timezone }}, {{ firstaccess }},\n{{ lastaccess }}, {{ lastlogin }}, {{ currentlogin }}, {{ lastip }},\n{{ secret }}, {{ picture }}, {{ url }}, {{ descriptionformat }},\n{{ mailformat }}, {{ maildigest }}, {{ maildisplay }}, {{ autosubscribe }},\n{{ trackforums }}, {{ timecreated }}, {{ timemodified }}, {{ trustbitmask }},\n{{ imagealt }}, {{ lastnamephonetic }}, {{ firstnamephonetic }},\n{{ middlename }}, {{ alternatename }}, {{ lastcourseaccess }},\n{{ currentcourseaccess }}, {{ groupmember }}*\n\nThe email field has 4 variants:\n* `{{ email.full }}` - full address (user@my.example.com)\n* `{{ email.username }}` - only username (user)\n* `{{ email.domain }}` - only domain (my.example.com)\n* `{{ email.rootdomain }}` - root domain (example.com)\n\nAdditional tags become available if you have custom profile fields added.\nFor example, if you were to create the following custom profile fields:\n* `checkboxtest` - type Checkbox\n* `datetimetest` - type Date/Time\n* `droptest` - type Dropdown menu\n* `textareatest` - type Text area\n* `textinputtext` - type Text input\n\nYou would be able to use these tags:\n\n*{{ profile.checkboxtest }}, {{ profile.datetimetest }}, {{ profile.droptest }},\n{{ profile.textinputtext }}, {{ profile_field_checkboxtest }},\n{{ profile_field_datetimetest }}, {{ profile_field_droptest }},\n{{ profile_field_textareatest.text }}, {{ profile_field_textareatest.format }},\n{{ profile_field_textinputtext }}*\n\n\u003e **Note:** Profile field templates are case sensitive. `{{ username }}` and\n`{{ UserName }}` are two different fields!\n\n#### Split arguments\nMustache also allows you to split a single field into multiple values.\n\nSynopsis: `%split(fieldname|delimiter)`\n\nThis will return multiple cohort names, formed by splitting the field\nat boundaries specified by the delimiter.\n\n* `fieldname` : Profile field name. The same as a tag, but without '{{' and '}}'\n* `delimiter` : The boundary string. 1-5 characters.\n\n\u003e **Example:**\n\u003e\n\u003e User John fills the custom profile field \"Known languages\" with the value\n\u003e \"English, Spanish, Chinese\"\n\u003e\n\u003e The main template contains a line: `Language - %split(knownlanguage|, )`\n\u003e\n\u003e John will be enrolled in 3 cohorts:\n\u003e * *Language - English*\n\u003e * *Language - Spanish*\n\u003e * *Language - Chinese*\n\n\n### Empty field text (`secondrule_fld`)\nIf profile field is empty, it will be replaced with this value.\n\n\n### Replace array (`replace_arr`)\nIf the values in your profile are expected to be different from what you want\nyour cohort names to be, you can add replacement strings here.\n\nOne replacement per line, in the format: `old value|new value`\n\ne.g.: `Yoyodyne Propulsion Systems Incorporated|Yoyodyne`\n\n\u003e **Note:** Names must not be longer than 100 characters, or they will be\n\u003e truncated.\n\n\n### Ignore users (`donttouchusers`)\n\nA list of users to ignore when updating or syncing profiles. Accepts\ncomma-separated usernames.\n\n    admin,test,manager,teacher1,teacher2\n\n### Enable automatic removal from managed cohorts (`enableunenrol`)\n\nIf this setting is checked, users will also be removed from automatic cohorts\nthat they no longer appear to be a part of, when their profiles are updated or a\nsync occurs.\n\n\n## Usage example\n\nSay you have custom profile fields \"status\" (student, teacher or admin)\nand \"classcode\", and you want to enrol users into cohorts using both of them.\n\nYou could set your main template to:\n\n`{{ profile_field_classcode }} - {{ profile_field_status }}s`\n\nAnd empty field text to: `none`\n\n* A Y19A teacher would be added to a \"Y19A - teachers\" cohort\n* A Y19B student would be added to a \"Y19B - students\" cohort\n* An admin user with no classcode would be added to \"none - admins\"\n\nTo rename the \"none - admins\" cohort to something more readable, you could\nadd a value to the replace array field:\n\n`none - admins|Administrators`\n\nWhen an admin user syncs, they will now be enrolled in a cohort named\n\"Administrators\" instead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatalyst%2Fmoodle-local_cohortauto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatalyst%2Fmoodle-local_cohortauto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatalyst%2Fmoodle-local_cohortauto/lists"}