Restriction by course role

Availability conditions ::: availability_role
Maintained by Ulm University, Alexander Bias, Luca Bösch
Moodle availability plugin which lets users restrict resources, activities and sections based on roles

Restriction by course role v2.9-r1

Moodle 2.9
Released: Wednesday, June 1, 2016, 8:46 PM


Moodle availability plugin which lets users restrict resources, activities and sections based on roles


This plugin requires Moodle 2.9+


  • 2016-02-10 - Change plugin version and release scheme to the scheme promoted by, no functionality change
  • 2016-01-01 - Initial version


Install the plugin like any other plugin to folder /availability/condition/role

See for details on installing Moodle plugins


After installing, availability_role is ready to use without the need for any configuration.

Teachers (and other users with editing rights) can add the "Role" availability condition to activities / resources / sections in their courses. While adding the condition, they have to define the role which students have to have in course context to access the activity / resource / section.

If you want to learn more about using availability plugins in Moodle, please see


availability_role should work with all Bootstrap based Moodle Themes.

Motivation for this plugin

If your teachers want to restrict activities / resources / sections in their course to a subset of the course participants and these course participants share a common course role, this plugin is for you.

Have a look at an example: * Tim Teacher is an editing teacher in course A. * Carl Clueless and Steve Smart are Tim's student assistants. * As Moodle admin, you have already created a custom course role called "student assistant" in your Moodle installation. Carl and Steve have this role in course A to do their work. * If Tim wants to provide activities / resources / sections only for Carl and Steve in course A, for example a forum activity where they can discuss internal stuff, he had to do some workarounds in the past. The most popular solution was to put Carl and Steve into a group and restrict the activities / resources / sections to this group, but there were even more complicated workarounds.

With availability_role, Tim does not need any workarounds anymore. He is just able to restrict his activities / resources / sections to a certain course role and all users who have this role in the course context have access.


In Moodle, roles normally do not control things directly. Instead, roles contain (multiple) capabilities and these capabilities control things.

There is the capability moodle/course:viewhiddenactivities (see which is contained in the manager, teacher and non-editing teacher roles by default. If a user has a role which contains moodle/course:viewhiddenactivities, he is able to use an activity / resource / section even if the teacher has restricted it with availability_role to some other role.

Because of that, availability_role can't be used to hide activities / resources / sections from users who already are allowed to view hidden activities in the course. Use this availability restriction plugin wisely and explain to your teachers what is possible and what is not.

Further information

availability_role is found in the Moodle Plugins repository:

Report a bug or suggest an improvement:

Moodle release support

Due to limited resources, availability_role is only maintained for the most recent major release of Moodle. However, previous versions of this plugin which work in legacy major releases of Moodle are still available as-is without any further updates in the Moodle Plugins repository.

There may be several weeks after a new major release of Moodle has been published until we can do a compatibility check and fix problems if necessary. If you encounter problems with a new major release of Moodle - or can confirm that availability_role still works with a new major relase - please let us know on

Right-to-left support

This plugin has not been tested with Moodle's support for right-to-left (RTL) languages. If you want to use this plugin with a RTL language and it doesn't work as-is, you are free to send me a pull request on github with modifications.


Bence Laky Synergy Learning UK

on behalf of

University of Ulm kiz - Media Department Team Web & Teaching Support Alexander Bias

Version information

Version build number
Version release name
Stable version
MD5 Sum
Supported software
Moodle 2.9
  • Latest release for Moodle 2.9

Version control information

Version control system (VCS)
VCS repository URL