Skip to content

fix(academy): let staff preview unpublished course steps - #1127

Merged
Genyus merged 1 commit into
developfrom
fix/learndash-step-previews
Nov 16, 2026
Merged

Genyus merged 1 commit into
developfrom
fix/learndash-step-previews

Conversation

@Genyus

@Genyus Genyus commented Nov 16, 2026

Copy link
Copy Markdown
Member

Problem

Reviewers and Content Editors get "too many redirects" when previewing a Draft or Pending lesson, topic or quiz. Admins aren't affected.

With nested course URLs on, learndash_check_course_step sends non-admins (anyone without manage_options) who open a step outside its course URL to the step's permalink within its course. An unpublished step has no slug, so that permalink is the preview URL itself, and the request redirects to itself.

Fix

cbf-learndash-step-previews.php unhooks learndash_check_course_step from wp (at priority 9) when the request is a preview of a lesson, topic or quiz and the user can edit it. WordPress only treats a request for an unpublished post as a preview when the viewer can edit it, so learners' course URL checks are unchanged. LearnDash has no filter for this check.

Testing

Simulated front-end requests on production as a Reviewer (read-only), with the plugin loaded:

  • Quiz 7379 preview: served, no redirect (before: redirect to the same URL)
  • Lesson 5173 preview: served, no redirect
  • Published lesson 6639 outside its course: still redirected into the course

Not covered

The toolbar's View Quiz link on an unpublished step points to its nested course URL, which 404s for everyone, admins included, until it's published. That's WordPress behaviour for unpublished posts.

LearnDash redirects non-admins viewing a lesson, topic or quiz outside its
course URL to the step's nested permalink. An unpublished step has no slug,
so that permalink is the preview URL itself, and Reviewers hit a redirect
loop. Skip the check for previews by users who can edit the step.
@Genyus
Genyus merged commit 9b0ce1f into develop Nov 16, 2026
4 checks passed
@Genyus
Genyus deleted the fix/learndash-step-previews branch November 17, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant