ÿþ<?php /** * Automatically enroll a user in courses based on email domain. * rewrite from Agus's function. * @dev tony. */ function courses_auto_enroll($user_id){ $user_data = get_userdata($user_id); if (!$user_data) { error_log("courses_auto_enroll: No user data found for user_id $user_id"); return; } $email = $user_data->user_email; $email_array = explode('@', $email); if (isset($email_array[1]) && $email_array[1] != "") { $domain = get_page_by_title($email_array[1], OBJECT, "domain_course"); if (!$domain) { error_log("courses_auto_enroll: No domain_course found for domain {$email_array[1]}"); return; } $programs = get_field("programs", $domain->ID); if (empty($programs)) { error_log("courses_auto_enroll: No programs found for domain ID {$domain->ID}"); return; } foreach ($programs as $program) { ld_update_group_access($user_id, $program); error_log("courses_auto_enroll: Enrolled user $user_id in program $program"); } }else{ error_log("courses_auto_enroll: Invalid email domain for user $user_id"); } } Personal Membership - Egypt - Plastic Bank

Confirmation

Are you sure you want to remove this item from cart?

Personal Membership – Egypt

CA$1.00 / month

Claim your impact,
50 bottles on us

Every bottle provides increased income for a collection member.

By subscribing, you agree to the collection and use of your information as outlined in our Data Privacy Policy.