Tutor LMS automatic enroll
-
Hi everyone! Can someone help me figure out how to use code to automatically assign a specific Tutor LMS course to all users? So far, I tried this, but it doesn’t work:
add_action('init', 'enroll_all_users_in_specific_course'); function enroll_all_users_in_specific_course() { // Retrieve all users $users = get_users(); // Loop through each user foreach ($users as $user) { $user_id = $user->ID; if (function_exists('tutor_utils')) { $course_id = 21897; // Check if the user is already enrolled in the course if (!tutor_utils()->is_enrolled($course_id, $user_id)) { // Use the do_enroll function to enroll the user tutor_utils()->do_enroll($course_id, 0, $user_id); } } } }
Thanks for your help!
- You must be logged in to reply to this topic.