If you want to sell courses in a bundle or use a third party selling system or just want to enroll students manually, this code snippet will help you do that.
Student enrollment is done in two methods- free and paid. Tutor LMS maintains its own orders to determine if a user has purchased a course or not. Please have a look at this gist to get an idea about the available filters and options in the ordering system of Tutor LMS.
do_enrol is the function that starts the enrollment process for Tutor LMS. It needs 3 options-
$student_id to work. If there is no course ID found, the function exits immediately.
$order_id refers to WooCommerce order ID. If you are migrating from some other plugins and used WooCommerce to sell the courses, then you can use that for tracking purpose. But this field is not mandatory. If you want, you can set a default value of 0 for this field.
There is an action named
tutor_before_enroll it is fired right before the enrollment process is started. It passes the course ID and user ID to the order system of Tutor LMS and updates the
$enrolment_status to completed, pending or canceled. It also logs the enrollment time for the subscription-based systems.
When a new enrollment process is started, the default value for the course enrollment status is set to pending. When the system gets a confirmation from the eCommerce plugin such as WooCommerce, EDD or PMPRO, it changes the status to completed.
tutor_enroll_data is the filter that creates the orders. It has the following parameters-
To insert the enrollment data, you need to use
wp_insert_post along with the