How to create menu and only manager can see that menu

Re: How to create menu and only manager can see that menu

by Jon Bolton -
Number of replies: 7
Picture of Particularly helpful Moodlers Picture of Testers

The simplest way, without custom development, is to create an HTML block that only users with a certain role can see. When you've created the block...

  • With editing turned on, click on the Block settings icon.
  • Click on Assign roles in [name of your] block
  • Ignore the message about not being able to assign any roles here.
  • In your Administration block, you will see a link for Permissions
  • For the capability to View Block (bottom of the list), make sure that the role that you DO want to view the block HAS permission to do so (ie. is listed on the left), and roles that you do NOT want to view the block is prohibited from doing so (ie. is listed on the right).


Things to think about...

  • This works with any block (we use it to hide admin block from all students and then provide links in other places for reset password, view/edit profile, and badges - tidies up things a lot!).
  • You might need to create a specific role for your managers (but it's simple to duplicate an exiting role). This will ONLY work with roles.
  • You can use this trick on the default My Home/Dashboard and profile pages too, but it's a bit more difficult and requires access to the back end database for the contextid number of the block. But it's very effective and gives us a truly unique dashboard for some users.
Average of ratings: Useful (2)
In reply to Jon Bolton

Re: How to create menu and only manager can see that menu

by SVI eSolutions -

On the dashboard you cannot edit the roles permitted to view your block, as far as I can see... When you click on the edit icon you do not have the same options available to you as when you are on the front page or anyother place within moodle.


In reply to SVI eSolutions

Re: How to create menu and only manager can see that menu

by Moses Okpala -

I was having this problem but thank God I have found the solution. Let me try it

In reply to SVI eSolutions

Re: How to create menu and only manager can see that menu

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

It appears that the 'Assign Roles' link has gone for blocks on the Dashboard page - but if you have access to the backend database, you can trick Moodle if you know the contextid number of the block. I'll have a look at a site where  did this and see if I can get get a coherent set of instructions smile

Average of ratings: Useful (1)
In reply to Jon Bolton

Re: How to create menu and only manager can see that menu

by SVI eSolutions -

Hi Jon, I have acces to the backend database and am looking forward to your coherent set of instructions! 

In reply to SVI eSolutions

Re: How to create menu and only manager can see that menu

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

Sorry, just remembered about this.

Ok...

  1. When you edit the permissions of a block on a page other than the dashboard, the url is http://yourmoodle.com/admin/roles/permissions.php?contextid=nn. Make a note of that link minus the number (nn) at the end.
  2. Go to the block you want to change on the Dashboard and hover over the configure icon - the link will be something like http://yourmoodle.com/my/index.php?sesskey=h2fKmKThld&bui_editid=zz (ignore the sesskey bit).
  3. Find that zz number in the instanceid field in the mdl_context table in your database. Make a note of the id number in that record.
  4. Go to http://yourmoodle.com/admin/roles/permissions.php?contextid=nn and replace the nn number with the id number from the mdl_context table. You should be taken to the assign roles page for the block on the dashboard.




In reply to Jon Bolton

Re: How to create menu and only manager can see that menu

by Sheila Tan -

Hi Jon

In the Totara forums, someone suggested this same trick of assigning roles to a HTML block. 

Unfortunately, there seems to be no Block administration.

Please see screenshot below:

html block


These are the only edits available. There is no icon that indicates 'Assign Roles' to this block. 

Any idea why this is? 

Have the developers blocked this capability?


Appreciate your answers.