Is there a php function to to check if logged in user is a manager?

Is there a php function to to check if logged in user is a manager?

by Alberto Marin -
Number of replies: 1

I am doing some moodle customization for my company's LMS and need to add a drop-down menu that is only visible to admins and managers. I the admin verification is easy with

 is_siteadmin() 

But is there an existing similar function to verify managers?

Essentially what I'd like to write is a simple if statement.

 if(is_siteadmin() || is_manager()){}

Average of ratings: -
In reply to Alberto Marin

Re: Is there a php function to to check if logged in user is a manager?

by John Okely -

In moodle, we don't give someone the ability to do something directly based on their role (except for admin which should be able to do anything) but instead based on the capabilities their role has. This is so that you can customise a role to allow or not allow individual capabilities.

Not all sites will have a manager, but they may have a similar role created from the manager archetype. So to achieve this, you will need to add a new capability to your plugin, and give it to the manager archetype by default. Then in your code you can check if the current user has that capability. Then you can say that the manager archetype has that capability by default.

For more information there is a docs article here: https://docs.moodle.org/dev/Access_API