/** * Checks to see that an user has finished a lesson or not yet * Function return the ID of a course if the user has completed a lesson * Otherwise, return false * * @author TuNguyen * * @param null $lesson_id * @param null $user_id * * @return mixed */ function learn_press_user_has_completed_lesson($lesson_id = null, $user_id = null) { _deprecated_function(__FUNCTION__, '1.0', 'LP_User() -> has_completed_quiz'); if ($user = learn_press_get_user($user_id)) { return $user->has_completed_quiz($lesson_id); } return false; $lesson_id = learn_press_get_lesson_id($lesson_id); if (!$user_id) { $user_id = get_current_user_id(); } $completed_lessons = get_user_meta($user_id, '_lpr_lesson_completed', true); if (!$completed_lessons) { return false; } foreach ($completed_lessons as $courses) { if (is_array($courses) && in_array($lesson_id, $courses)) { return true; } } return false; }
/** * Checks to see that an user has finished a lesson or not yet * Function return the ID of a course if the user has completed a lesson * Otherwise, return false * * @author TuNguyen * * @param null $lesson_id * @param null $user_id * * @return mixed */ function learn_press_user_has_completed_lesson($lesson_id = null, $user_id = null) { $lesson_id = learn_press_get_lesson_id($lesson_id); if (!$user_id) { $user_id = get_current_user_id(); } $completed_lessons = get_user_meta($user_id, '_lpr_lesson_completed', true); if (!$completed_lessons) { return false; } foreach ($completed_lessons as $courses) { if (is_array($courses) && in_array($lesson_id, $courses)) { return true; } } return false; }