1

Is there a web service in Moodle that can be used to assign a global role, e.g. course creator, to a user based on his ID?

1 Answers1

0

You can use core_role_assign_roles for assign roles and for unassign use core_role_unassign_roles.

gnuwings
  • 950
  • 7
  • 8
  • You are perfect, thanks... it works on a system, but not in a coursecategorie... i want to give the user id: 4 for coursecategorie: 1049 the role: 2 (coursecreater) Here is my Curl: MyMoodle/webservice/rest/server.php?wstoken=MyToken&wsfunction=core_role_assign_roles&moodlewsrestformat=json&assignments[0][roleid]=2&assignments[0][userid]=4&assignments[0][contextid]=1&assignments[0][contextlevel]=coursecat&assignments[0][instanceid]=1049 i get as answer "null", it works. But i do not see the user with the id 4 in the coursecategorie 1049 as coursecreater. Whats wrong on my curl? –  Jul 06 '21 at 08:31
  • If i use --> assignments[0][contextid]=0<--- it works for course_categories –  Jul 06 '21 at 09:31