Note: You are currently viewing documentation for Moodle 3.11. Up-to-date documentation for the latest stable version of Moodle may be available here: Switch roles.

Switch roles

From MoodleDocs

Switching temporarily to another role

The switch roles feature allows a user to switch temporarily to another role from the user menu 'Switch role' so that they can see what the course would look like to someone with that role.


Switching roles is not perfect because you remain the same user, and your user may not have things like grades, which will make some student views look different than a real student might see. To get an 100% accurate view, the best thing to do is create a test student account and enrol it in your course. It is useful to have this logged-in on another browser so you can quickly switch back and forth.

The capability moodle/role:switchroles is required for the role so you can see the role switch in the user menu. The capability is allowed for the default roles of manager and teacher.

Another way to see a student view is to "Log in as" one of your real students. You need the special capability user:loginas for this, and you do need to be careful that you don't accidentally change things for that student.

Site administration settings

The list of roles that you can switch to is set in the "Allow role switches" tab in 'Define roles' in the site administration.

Enabling a non-editing teacher to switch roles

  1. Go to Site administration / Users / Permissions / Define roles and click the 'Allow role switches' tab.
  2. For the non-editing teacher row, make sure that the checkboxes for Student and Guest are ticked.
  3. Save changes.
  4. Click the 'Manage roles' tab and edit the non-editing teacher role.
  5. Enter 'switch' in the filter field, then tick the checkbox to allow the capability 'Switch to other roles' (moodle/role:switchroles).
  6. Save changes.

See also