unenrol users enrolled via web services

unenrol users enrolled via web services

by Nick Freeman -
Number of replies: 3

We have been using web services to create groups and enrol users for a few years.  We also use the web services to unenrol users too.  Or so we thought.

Once a user should no longer have access to a course, the web service runs and removes the relevant row from mdl_role_assignments table.  However, the equivalent row remains in the mdl_user_enrolments table. 

When we call the web services to enrol users we call both functions core_role_assign and enrol_manual_enrol_users.  However, for unenrolments, there is only the core_role_unassign function. 

How can we remove the user enrolment as well?

(We are also creating groups and putting users into them.  If we don't use the enrol_manual_enrol_users function, it complains that we can't put them into the group because they're not enrolleed on the course).

Any help or guidance would be appreciated. 

thanks
Nick

Average of ratings: -
In reply to Nick Freeman

Re: unenrol users enrolled via web services

by Reghyna Rodriguez -

In the function enrol_manual_enrol_users in your web service send the parameter "suspend" equal to "1" value

In reply to Reghyna Rodriguez

Re: unenrol users enrolled via web services

by Nick Freeman -

thank you very much Reghyna for responding.  We'll give that a try - we hadn't realised that function could accept that parameter.