CoursePress Custom Requirement

I want to make our users able to enroll to two or more Courses at the same time when they pay for one or once. I’m using WooCommerce for CoursePress payment.

Can you please guide me in how this can be done?

  • Rupok
    • Ex Staff

    Hi Bela,

    I’ve requested our Second Level Support (SLS) team to provide their valuable feedback on this. I believe, they will come up with their feedback very soon.

    Please keep in mind, our SLS people work around the clock and they have to deal with lots of critical issues and other things. So it may take a little while for them to check this and provide a feedback. I will appreciate your patience.

    Have a nice day. Cheers!

    Rupok

  • Panos
    • SLS

    Hi Bela ,

    This isn’t support out of the box but there are some hooks that can be used to achieve this.

    Could you please try adding the following snippet in you functions.php ( or a mu-plugin ):

    add_action( 'coursepress_student_enrolled', 'wpmudev_student_additional_enrolments', 10, 2 );
    function wpmudev_student_additional_enrolments( $student_id, $course_id ){

    remove_action( 'coursepress_student_enrolled', 'wpmudev_student_additional_enrolments', 10 );

    $main_course_id = 5433;
    $courses_ids = array( 5534, 5567 );

    if( $main_course_id != $course_id ){
    return;
    }

    $key = sprintf( 'course_%d_woo_payment_status', $course_id );
    $status = get_user_meta( $student_id, $key, true );

    if( $status != 'completed' ){
    return;
    }

    foreach( $courses_ids as $c_id ){
    CoursePress_Data_Course::enroll_student( $student_id, $c_id );
    }

    }

    Then replace in

    $main_course_id = 5433;

    the id of your course that is being bought

    and in the line:

    $courses_ids = array( 5534, 5567 );

    add the ids of he other courses that you like your student to enroll.

    Please let us know if his helps :slight_smile:

    Cheers!