I think the way to do this is to have a "switch" using a Variable.
When the Teacher code is entered (for example), have a variable switch from e.g. False to True.
For every slide on e.g. the Teacher area, make the first Trigger check the Variable is True, and if not, route the slide back to the "Student" area.
Sorry I cannot spend more time on a prototype of this, but I think that is how you can make this work.
Alternatively, I would lose the side menu for all areas altogether, and just use a pictorial menu slide and custom buttons so anyone can return to "their" menu when they want to, but no other group can see it.