• Resolved adrienperinot

    (@adrienperinot)


    Hi,

    I need to trigger the enrolment in a course of a given user (whose user ID I already know).

    So far I have this :

    $course_id = '442';
    $userid=8;
    Sensei_Utils::user_start_course($userid, $course_id);

    However it is only adding the user to the course list, but not actually <b>enrolling</b> him/her.

    What would be the proper way to enrol a given user ? Is there any other method that I have missed in the Sensei_Utils class ?

    Thanks a lot by advance,

    Adrien

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Giannis

    (@gikaragia)

    Hello Adrien,

    in the latest version enrollment is handled by enrollment providers. You can enroll a user with:

    
    $manual_enrolment_provider = Sensei_Course_Enrolment_Manager::instance()->get_manual_enrolment_provider();
    $manual_enrolment_provider->enrol_learner( $user_id, $course_id );
    

    Giannis

    Thread Starter adrienperinot

    (@adrienperinot)

    I saw your answer on time but I forgot to answer, sorry about this ??

    Thanks a lot, much clearer for me ??

    Adrien

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP : How to trigger enrolment for a given user ?’ is closed to new replies.