At the moment I am able to enrol a user into a course using the following code.
enrol_try_internal_enrol($_POST['course_id'], $_POST['user_id'], $_POST['role_id'], time());
The issue is that it enroles the user as MANUAL, but I need the user to be enroled as SELF ENROLMENT.
How can I achieve that? What function can I use?