I have a button that I want only those that have teachers role to see.
I have set the following via code and admin area and the changes done in the admin area seem to be ignored.
For the first image, all people get to see the button, which is as expected.
For the second image, nobody sees the button (not talking about admin).
I also tried to set from CONTEXT_MODULE to CONTEXT_SYSTEM (and change to version to force update) with not result.
I also tried to set prevent for registered user and allow for teacher with no result.
Any idea what I am doing wrong? Or a method / piece of code to do the "show button only to some roles"?
Thank you in advance (will leave the existing code and images below).
////////
in access.php
////////
$capabilities = [
'local/myplugin:access' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read ',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => [
'user' => CAP_ALLOW
]
]
];
////////
in somefile.php
////////
if (!has_capability('local/myplugin:access', context_system::instance()){
echo 'Cannot access';
} else{
echo 'Can access';
}
////////