General developer forum

new capability not working

 
Picture of gus smith
new capability not working
 

Hello, I'm writing in this forum, because I have doubts about how to use moodle capabilities.

I am developing a block whose content should only be visible to administrators, teachers and non editing teachers.

I show you how is my code:


Capability definition in access.php

capability code


Check capability.

check capability 1


My block is located in site-index.

I'm logged in as a teacher, but it shows the message you do not have permission!!

my block

Could you help me know what I'm doing wrong?

thank you very much to all!!


 
Average of ratings: -
Davo
Re: new capability not working
Core developersParticularly helpful MoodlersPlugin developers

Do you have Debugging set to developer level?

If you switch it on, I suspect you *might* get a warning message about 'unknown capability'.

If that is the case, then you need to increase the version number of your plugin, in order to tell Moodle that it needs to check all the files in your plugin's db/ folder to see if there are any changes.


 
Average of ratings: -
Picture of gus smith
Re: new capability not working
 

Hello again

I have the debugging activated in developer mode, but it does not show any error or warning message.

Increase the version of my block in the version.php file.

I do not understand where the error is.


depuracion


I'm logged in as a tutor


login tutor

 
Average of ratings: -
Davo
Re: new capability not working
Core developersParticularly helpful MoodlersPlugin developers

It looks like your block is displaying on the front page of the site.

Is the test user a tutor at the site level, or just at a course level?

If they're only a tutor at the course level (the usual case), then they won't have any of the tutor-specific capabilities at the site level.


 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: new capability not working
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Section 13.2 here may help you understand Moodle's roles and permissions model.

 
Average of ratings: -