Hide navigation block from students, but not other roles

Hide navigation block from students, but not other roles

by tim st.clair -
Number of replies: 2
Picture of Particularly helpful Moodlers Picture of Plugin developers

In Moodle 2.7 and above, is it possible to hide the navigation block from students but not other roles. We are using single sign on and automatically loading courses from an external URL and don't want the users to use other site features such as the dashboard, homepage, or category lists to navigate to other courtses. https://docs.moodle.org/30/en/Navigation_block doesn't offer a proper solution; just using css to hide .block_navigation is ok except its still present in the page and can muck up certain themes but is current solution; https://moodle.org/mod/forum/discuss.php?d=237673 has a hack that's a hack and therefore will probably break in the future. Prohibiting block/navigation:addinstance for the student role doesn't seem to do anything, but it's not the student adding the instance; prohibiting moodle/block:view for the student role for the navigation block also does nothing...

Average of ratings: -
In reply to tim st.clair

Re: Hide navigation block from students, but not other roles

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Tim,

The capability moodle/block:view can be used for hiding the navigation block, but only if applied using a system role. For example, you could prevent moodle/block:view for the authenticated user role, then the block would be hidden from everyone except admins and managers (with a system role with moodle/block:view allowed).

The reason why prohibiting moodle/block:view for the student role doesn't do anything is because normally users are assigned the role of student in a course i.e. it is not a system role. Please see the documentation Assign roles for more details.

In reply to tim st.clair

Re: Hide navigation block from students, but not other roles

by Hartmut Scherer -

Hi Tim,

Hiding the navigation block to students can be accomplished by setting the permission for the authenticated user and the student in "view block" to prevent. 

Navigation block - prevented for authenticated user

















Navigation block prevented for student role
















With kind regards,

Hartmut

Average of ratings: Useful (1)