Programmatically Enroll Student
-
I’m trying to enroll a student programmatically when a payment occurs from a 3rd party service.
I dug through the code quite a bit and this is what I’ve come up with. Can you please tell me if there’s a better/easier or more correct way?
$course_id = 31; $user = learn_press_get_user($obj->user_id, false); $item = array( 'order_item_name' => 'ADHD Course', 'item_id' => $course_id, 'quantity' => 1, 'subtotal' => $obj->amount, 'total' => $obj->total ); $order = learn_press_create_order(); $order->set_customer_note( '' ); $order->set_status( 'lp-completed' ); $order->set_total( $obj->total ); $order->set_subtotal( $obj->amount ); $order->set_user_ip_address( learn_press_get_ip() ); $order->set_user_agent( learn_press_get_user_agent() ); $order->set_created_via( 'external' ); $order->set_user_id( $obj->user_id ); $order->save(); $order->add_item( $item ); $user->enroll($course_id, $order->id);
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Programmatically Enroll Student’ is closed to new replies.