Error on api resto to asing role to user

Re: Error on api resto to asing role to user

by Eliseo Montenegro -
Number of replies: 1
through the api I create the user,
to assign a course to the function I have to pass the user id and the id role
$enrolment = array( 'roleid' => $role_id, 'userid' => $user_id, 'courseid' => $course_id );
$enrolments = array( $enrolment );
$params = array( 'enrolments' => $enrolments );

$response = call_moodle( 'enrol_manual_enrol_users', $params, $token );