Get roles of a user using webservice API

Re: Get roles of a user using webservice API

by Davo Smith -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The closest you can get, as far as I am aware, is core_user_get_course_user_profiles() - given a list of userids and courseids, it will give you the roles that each user has in the given course. In Moodle terms, the question doesn't make any sense in any other context, as students are only defined as such on a course level (the same user can be a student on one course and a teacher on another).

I suggest you should probably step back and try to figure out what information you are actually wanting - Moodle only uses roles as a way of allocating a group of capabilities to a user in a particular section of the site. User's aren't really "students" or "teachers", but "someone who is allowed to do X, Y & Z" at this particular place on the site.