How to lock or disable a block region?

How to lock or disable a block region?

by Luis De Sousa -
Number of replies: 4

Best regards. I need to prevent users add to or moving blocks to a custom region. Is it possible to lock or disable a region so that the user can not modify it?

Average of ratings: -
In reply to Luis De Sousa

Re: How to lock or disable a block region?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Look at the capabilities in the system and see if there is one that can be removed from the role that your users have to achieve what you want.

In reply to Gareth J Barnard

Re: How to lock or disable a block region?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Thinking about this again, there might be a solution with custom capabilities in the theme.  But the code would take a day or more to write and test.  Therefore would need to be funded.

In reply to Gareth J Barnard

Re: How to lock or disable a block region?

by Luis De Sousa -

Thanks for the help. I'm working on your suggestion. Best Regards

In reply to Luis De Sousa

Re: How to lock or disable a block region?

by Rob Davenport -

I too am interested if there are any solutions to this, as we looked at this requirement some time ago, and came up blank - however a bit of a work around we used without modifying Moodle itself was to target and disable the editing of the blocks that should be placed consistently on every page for the sake of navigation, usability and user sanity.

It's not fool proof, but may go part way towards what you want to achieve

For example, if you want the Admin block staying put, the following is added to the theme CSS:

#region-pre .block_settings .commands {
display: none;
}

Different selectors can be added targeting each block you want to apply this to. Note: Not even Admins can see controls for the block once implemented - though any web developer can use the inspector to temporarily disable the CSS to make setting changes.

It doesn't prevent users from placing other blocks above this block (if they have the capability), but at least it should stay in the region.

Cheers, Rob.