• Hi there,

    Is there a function that allows me to easily enroll users to a course?

    Something like learnpress_enroll_user( $user_id, $course_id ) or do I have to create an order inside LearnPress to enroll the user in my custom plugin?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support brianvu-tp

    (@briantp)

    Hi,

    You can go to LearnPress -> Order then create the order for the user to they can enroll on the course.

    Thanks

    Plugin Support brianvu-tp

    (@briantp)

    You can refer use to this code to meet

    
    $controller = new LP_REST_Courses_Controller();
    		$request    = new WP_REST_Request();
    		$request->set_param( 'id', $course_id );
    		$response    = $controller->enroll_courses( $request );
    

    variable $user will auto get via function “learn_press_get_current_user”

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP Function to enroll user’ is closed to new replies.