Это код, который я использовал для достижения желаемого результата: но это всегда приводит к критической ошибке.
Код: Выделить всё
function sync_lesson_completion($lesson_id, $user_id, $course_id) {
// Get the course that contains the lesson
$course = get_post($course_id);
// Check if the course has shared steps enabled
$shared_steps_enabled = get_post_meta($course_id, '_sfwd-courses_sharedsteps_enabled', true);
// Check if shared steps are enabled and the lesson is shared
if ($shared_steps_enabled && !empty($lesson_id)) {
// Get all the courses where the lesson is shared
$shared_courses = learndash_get_courses_by_step($lesson_id, 'sfwd-lessons');
// Loop through the shared courses
foreach ($shared_courses as $shared_course_id) {
// Skip the current course
if ($shared_course_id == $course_id) {
continue;
}
// Mark the lesson as completed for the user in the shared course
learndash_update_user_activity($user_id, $lesson_id, 'sfwd-lessons', $shared_course_id, true);
}
}
}
// Hook into the lesson completion action
add_action('learndash_lesson_completed', 'sync_lesson_completion', 10, 3);
Подробнее здесь: https://stackoverflow.com/questions/766 ... -learndash