This plugin provides a way to restrict access to Moodle activities and resources based on the user's browser user agent.
- Download the plugin.
- Extract the contents of the plugin to the
availability/condition/useragent
directory in your Moodle installation. - Visit the Moodle admin page to complete the installation.
- Navigate to the course where you want to add the restriction.
- Edit the settings of the activity or resource you want to restrict.
- In the "Restrict access" section, click "Add restriction...".
- Select "User agent".
- Enter the user agent regex you want to restrict access to, without delimiters, e.g.
^.*(Chrome|Firefox).*$
. - Save your changes.
Use case: check and dispay a message to the user on the course page of the user is not at least on Chrome 120, Firefox 130, or Safari 18.
- Create a Label containing the test "Your browser version is unsupported." (or equivalent message).
- Add a "User agent" access restriction rule with the following RegExp:
^.*(Firefox.*13\d|Chrome.*12\d|18\..*Safari).*$
- Chose the
must not
option instead of themust
option to invert the access condition. - Click the
eye
icon next to the access rule to make it that the Label is not displayed when the condition is met.
The effect is that the label containing the warning is only displayed if the client browser versoin does not match the criterion.
This plugin is licensed under the GNU GPL v3 or later.
This plugin was developed by Nicolas Dunand [email protected] based on the plugin availability_ipaddress by Luuk Verhoeven [email protected].