LMS Tutor: Bulk Programmatically Enroll Students (Woocommerce)


I have migrated to LMS Tutor, but my site already has orders with previous LMS using woocommerce. how I can bulk assign my customer to specifics courses in LMS Tutor based on their purchase?

There is documentation about programmatically enroll students.
here a link

but I don’t know how to use it in bulk.

in progress 0
Ayu Edwina 2 years 2020-12-13T13:10:23-05:00 1 Answer 21 views 0

Answer ( 1 )


    Guys, just to help everyone is trying to use this, please, follow the way I’ve used and worked like a charm. Ps.: has_aplay() is a function we have on our theme, this basically checks if the user has access to the content, see:

    # TUTOR - manualy enroll user (enroll data)
    add_filter('tutor_enroll_data', function ($data) {
    if ( has_aplay() ) $data['post_status'] = 'completed';
    return $data;

    # TUTOR - manualy enroll user (do_enroll)
    add_action( 'tutor_before_enrolment_check', function ( $course_id, $user_id ) {
    if ( tutor_utils()->is_enrolled($course_id, $user_id) ) {
    return true;

    if ( has_aplay() ) {
    return tutor_utils()->do_enroll($course_id, 0, $user_id);
    }, 10, 2 );

    Hope this helps. Thanks.

Leave an answer