Authentication: Autoenrol cohort

Maintained by Picture of Dan MarsdenDan Marsden, Picture of Catalyst ITCatalyst IT
This Authentication plugin automatically assigns users into cohorts based on information in their user profile fields.

Autoenrol cohort 0.2

Release notes

This Authentication plugin automatically enrol users into cohorts.

Cohort name depends on user profile field.

How to use:

1. Copy plugin into /moodle/auth directory
2. Go to Site administration - Notifications page and install it
3. Go to Plugins - Authentication and enable plugin
4. Configure main rules (template for cohort name)
second rule (replace empty field)
and replacement array
5. ???

Cohorts are created in CONTEXT_SYSTEM

You have a custom profile fields "status" (student, teacher or admin) and "course".

You wnat to enrol many users into cohorts like "course - status" than enrol cohorts into courses.

At configuration page set:
Main template to %profile_field_course - %profile_field_status (1 template per line, before profile fields type %)
Empty field text (When field is empty this value used) to none

When 1st course student logins, he enrol to cohort named "1 - student"
When 1st course teacher logins, he enrol to cohort named "1 - teacher"
When admin logins, he enrol to cohort named "none - admin" (Course not set, status - admin)

To rename "none - admin" cohort to "Administration" you must set a replacement array field at the configuration page (1 replacement per line, old_value|new_value)
In our case: none - admin|Administrator

When admin logins, he enrol to cohort named "Administrator"

This plugin only create cohorts and enrol users to it.
To find the list of profile fields go to User - > User bulk operation and download 1-2 users.
Moodle 2.0, 2.1, 2.2

Version information

Version build number
Version release name
Can be updated from
0.1 (2011112700)
Can be updated to
0.3, 0.31 (2012040219), 0.4 (2012050512), 1.0 (2013051812)
Release candidate
MD5 Sum
Supported software
Moodle 2.1, Moodle 2.0, PHP 5.3, Moodle 2.2
  • This is the latest release for Moodle 2.0
  • The more recent release 0.4 (2012050512) exists for Moodle 2.1
  • The more recent release 0.5 (2012071912) exists for Moodle 2.2

Default installation instructions for plugins of the type Authentication

  1. Make sure you have all the required versions.
  2. Download and unpack the module.
  3. Place the folder (eg "myauth") in the "auth" subdirectory.
  4. Visit to finish the installation