Browse: Home / Snippets /

Auto-enrol a user into specific courses after they complete registration

Contents


Snippet #

Important: All snippets are provided as-is without support or guarantees. These snippets are provided as guidelines for advanced users looking to customize LearnDash. For any additional help or support with these snippets, we recommend reaching out to a LearnDash Expert.


add_action( 'user_register', function( $user_id ) {
    // enter course ID's below for the courses you want the user auto-enrolled in
    $course_ids = array(123,234,345);
    
    if ( $user_id > 0 ) {
        learndash_user_set_enrolled_courses( $user_id, $course_ids );
    }
}, 10, 1 );