Search code examples
phpwordpresslmslearndash

How can I mark a course as completed for a specific user in LearnDash? I want a function that will mark all lessons, topics, quizzes as complete


I found the "learndash_mark_complete" but it shows a button to complete. I want to complete it programatically for a few users in a few courses


Solution

  • I believe you're looking for the learndash_process_mark_complete() function, which according to LearnDash "Updates the user meta with completion status for any resource."

    It accepts the following arguments:

    • $user_id - User ID. Default null.
    • $postid - Optional. The ID of the resource like course, lesson, topic, etc.
    • $onlycalculate - Optional. Whether to mark the resource as complete or just calculate it.
    • $course_id - Optional. Course ID.