Block options: choose login/booking link targets, optional auto-redirect #51

Closed
opened 2026-07-05 19:14:55 +00:00 by thatguygriff · 0 comments
Owner

Problem

Two of the Gutenberg blocks render links whose targets cannot be configured:

  • The Lesson Booking block (us-scheduler/booking) shows a "log in to book a lesson" link to logged-out visitors. It always points at the WordPress login screen (wp-login.php), even when the site has a front-end student login page.
  • The Student Login block (us-scheduler/student-login) shows a "View available lessons" link to visitors who are already logged in. It points at the login page itself, so it effectively goes nowhere.

Proposed behaviour

  • The booking block gets a Login page option (dropdown of published pages) controlling where the log-in link sends logged-out visitors. Default stays the WordPress login screen.
  • The student-login block gets a Booking page option controlling where the logged-in link points and where students land after logging in. Default stays the current page.
  • Both blocks get an auto-redirect toggle, off by default: instead of showing the link, logged-out visitors on the booking page are redirected to the login page, and logged-in visitors on the login page are redirected to the booking page.

Related bug found during implementation

Using any of the four shortcodes bare (e.g. [us_booking] with no attributes) throws a TypeError: WordPress core's shortcode_parse_atts('') passes an empty string where the strictly-typed render(array $atts) methods expect an array. The shortcode callbacks need to normalize non-array attribute values.

## Problem Two of the Gutenberg blocks render links whose targets cannot be configured: - The **Lesson Booking** block (`us-scheduler/booking`) shows a "log in to book a lesson" link to logged-out visitors. It always points at the WordPress login screen (`wp-login.php`), even when the site has a front-end student login page. - The **Student Login** block (`us-scheduler/student-login`) shows a "View available lessons" link to visitors who are already logged in. It points at the login page itself, so it effectively goes nowhere. ## Proposed behaviour - The booking block gets a **Login page** option (dropdown of published pages) controlling where the log-in link sends logged-out visitors. Default stays the WordPress login screen. - The student-login block gets a **Booking page** option controlling where the logged-in link points and where students land after logging in. Default stays the current page. - Both blocks get an **auto-redirect** toggle, **off by default**: instead of showing the link, logged-out visitors on the booking page are redirected to the login page, and logged-in visitors on the login page are redirected to the booking page. ## Related bug found during implementation Using any of the four shortcodes bare (e.g. `[us_booking]` with no attributes) throws a TypeError: WordPress core's `shortcode_parse_atts('')` passes an empty string where the strictly-typed `render(array $atts)` methods expect an array. The shortcode callbacks need to normalize non-array attribute values.
thatguygriff added the enhancement label 2026-07-05 19:14:55 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Unsupervised/unsupervised-scheduler#51