Send students to a chosen page when registration succeeds #116

Merged
thatguygriff merged 1 commits from feature/registration-success-redirect into main 2026-07-28 15:04:44 +00:00
Owner

Adds an after-registration destination to the Student Registration block, extending its existing email-confirmation page setting rather than adding a second one.

The sidebar panel After email confirmation becomes After registration, and the page it selects gains a Redirect automatically toggle.

Behaviour

State Result
Validation error / ?us_confirmed=expired Error shown inline, never redirected past
"Check your email to confirm" Message shown, never redirected past
Invited student, now logged in Success message + "Continue to your account" link (new)
Email confirmed (ready / 1) Success message + "Sign in to your account" link (unchanged)
Either of the last two, toggle on Redirected to the chosen page instead of showing the link

Only those two finished states qualify — RegistrationPage::isRegistrationComplete(). The redirect itself runs from BlockRegistrar::maybeRedirectAfterRegistration() on template_redirect, since block rendering happens after output has started and is too late to send a Location header. The query-flag check runs before the post content is parsed, so an ordinary page view does not pay for a third block scan.

Judgement calls

  • No login-screen fallback for this redirect. Unlike the Booking block, with no page chosen nothing happens and the link shows as before. Sending an invited student who is already signed in to wp-login.php would be wrong, so continueUrl() (nullable) sits beside the existing loginUrl() (falls back to the login screen) and the two paths use whichever is right.
  • The invited-student success gains a link. It previously rendered a confirmation message with no link at all, so there was nothing for the toggle to replace.
  • Removed a now-provably-unreachable $successType === 'invite' branch from templates/frontend/register-page.php rather than leave a second, link-less copy of that markup to drift — render() returns before the template for logged-in visitors.

No schema change, so no version bump.

Tests

All run on the rebased branch:

  • composer test629 tests, 1808 assertions, OK
  • composer lint — PHPStan level 10, no errors
  • composer cs — PHPCS clean

New coverage: isRegistrationComplete() across all eight registration states, the invited-student link with and without a page chosen, continueUrl() with no resolvable page, and five BlockRegistrar auto-redirect cases (fires when finished; skipped when unfinished, not opted in, no page chosen, or pointing at its own page).

Closes #115

🤖 Generated with Claude Code

Adds an after-registration destination to the **Student Registration** block, extending its existing email-confirmation page setting rather than adding a second one. The sidebar panel **After email confirmation** becomes **After registration**, and the page it selects gains a **Redirect automatically** toggle. ## Behaviour | State | Result | |---|---| | Validation error / `?us_confirmed=expired` | Error shown inline, never redirected past | | "Check your email to confirm" | Message shown, never redirected past | | Invited student, now logged in | Success message + **"Continue to your account"** link (new) | | Email confirmed (`ready` / `1`) | Success message + "Sign in to your account" link (unchanged) | | Either of the last two, toggle on | Redirected to the chosen page instead of showing the link | Only those two *finished* states qualify — `RegistrationPage::isRegistrationComplete()`. The redirect itself runs from `BlockRegistrar::maybeRedirectAfterRegistration()` on `template_redirect`, since block rendering happens after output has started and is too late to send a `Location` header. The query-flag check runs before the post content is parsed, so an ordinary page view does not pay for a third block scan. ## Judgement calls - **No login-screen fallback for this redirect.** Unlike the Booking block, with no page chosen nothing happens and the link shows as before. Sending an invited student who is *already signed in* to `wp-login.php` would be wrong, so `continueUrl()` (nullable) sits beside the existing `loginUrl()` (falls back to the login screen) and the two paths use whichever is right. - **The invited-student success gains a link.** It previously rendered a confirmation message with no link at all, so there was nothing for the toggle to replace. - Removed a now-provably-unreachable `$successType === 'invite'` branch from `templates/frontend/register-page.php` rather than leave a second, link-less copy of that markup to drift — `render()` returns before the template for logged-in visitors. No schema change, so no version bump. ## Tests All run on the rebased branch: - `composer test` — **629 tests, 1808 assertions, OK** - `composer lint` — PHPStan level 10, no errors - `composer cs` — PHPCS clean New coverage: `isRegistrationComplete()` across all eight registration states, the invited-student link with and without a page chosen, `continueUrl()` with no resolvable page, and five `BlockRegistrar` auto-redirect cases (fires when finished; skipped when unfinished, not opted in, no page chosen, or pointing at its own page). Closes #115 🤖 Generated with [Claude Code](https://claude.com/claude-code)
thatguygriff added 1 commit 2026-07-28 14:00:29 +00:00
Send students to a chosen page when registration succeeds
CI / Tests (PHP 8.2) (pull_request) Successful in 49s
CI / Tests (PHP 8.1) (pull_request) Successful in 1m0s
CI / Coding Standards (pull_request) Successful in 2m51s
CI / PHPStan (pull_request) Successful in 2m57s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m40s
CI / Build Plugin Zip (pull_request) Skipped
CI / No Debug Code (pull_request) Successful in 2s
13d6b3e14e
The Student Registration block's "After email confirmation" panel becomes
"After registration": the page it selects is now where a newly registered
student continues to, and a new autoRedirect toggle sends them there
instead of showing the link.

Only the two finished states qualify (RegistrationPage::isRegistrationComplete):
an invited student who is now logged in, and a self-signup back from the
emailed confirmation link. A validation error, an expired confirmation
link, and the intermediate "check your email" step all stay on the page so
their message is read.

The invited-student success previously had no link at all; it gains a
"Continue to your account" one. That path deliberately has no
WordPress-login-screen fallback — pointing someone already signed in at the
login screen helps nobody — so continueUrl() distinguishes "no page chosen"
from "page chosen", and the redirect does nothing until one is picked.

Closes #115

Co-Authored-By: Claude Opus 5 <[email protected]>
thatguygriff merged commit 17487cde46 into main 2026-07-28 15:04:44 +00:00
thatguygriff deleted branch feature/registration-success-redirect 2026-07-28 15:04:44 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Unsupervised/unsupervised-scheduler#116