assign roles relative to a user through web service moodle

assign roles relative to a user through web service moodle

by Yazan Mohmmad -
Number of replies: 1

Hello,

what is the web service that is going to assign a Parent user to his child,

i used this one

$functionname = 'core_role_assign_roles';
header('Content-type: text/plain; charset=utf-8');
$restformat = '&moodlewsrestformat=json' ;
$serverurl = domainname . '/webservice/rest/server.php'. '?wstoken=' .
                    token . '&wsfunction='.$functionname;
$serverurl = $serverurl . $restformat;

$http = new Client();
$assignments = array('roleid'=>9, 'userid'=>$student_id, 'contextid'=> $guardian_id);
$assignmentsArray = array(0 => $assignments);
$resp = $http->post($serverurl ,['assignments' => $assignmentsArray]);
$resp = $resp->json;



but this does not help, am i missing something?

Average of ratings: -
In reply to Yazan Mohmmad

Re: assign roles relative to a user through web service moodle

by Yazan Mohmmad -

Ok i found i needed contextid for a user instead of userid, but how to get contextid ?