Hello .
I still have some problems with the role system , I wanted to check if a user is a teacher in any group of a course, but I dont seem to make it work.
this is what I have so far.
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
if(has_capability('moodle/legacy:teacher', $context,$user->id)){
echo "Is theacer";
}
it works but it only shows as teachers the one that are in the current group but not on all the groups in the course, I am using a foreach to go through the users and check which has teacher role in any group.
Hope you can help me
Hi Victor,
Sorry I can't answer your question, but I'm going to move your discussion to the roles and capabilities forum, where hopefully someone will be able to help.
Sorry I can't answer your question, but I'm going to move your discussion to the roles and capabilities forum, where hopefully someone will be able to help.
Why do you want to know if a user is a teacher? What are you going to do, or not do, based on that knowledge?
has_capability does not know anything about groups, I suspect the group restriction is coming from elsewhere in the code. Where is $user coming from.
has_capability does not know anything about groups, I suspect the group restriction is coming from elsewhere in the code. Where is $user coming from.