Link a signed-in visitor to the configured continue page
The registration page's already-logged-in branch returned a bare sentence with nowhere to go, leaving the visitor to find their own way to their account. The invited-student branch a few lines above already built exactly the link that was missing. Extract that into continueLink() and use it for both logged-in outcomes. There is deliberately still no wp_login_url() fallback: sending someone already signed in to the login screen is the same dead end with extra steps, so with no page configured there is no link. Both messages now carry the us-register-form wrapper and enqueue the plugin stylesheet, which the invite branch emitted markup for but never loaded. Closes #131
This commit is contained in:
@@ -65,24 +65,21 @@ class RegistrationPage {
|
||||
$registered = sanitize_key( Val::string( wp_unslash( $_GET['us_registered'] ?? '' ) ) );
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
if ( self::RESULT_INVITE === $registered ) {
|
||||
// An invited student is done the moment they land here logged in,
|
||||
// so this is where their "continue" link belongs. The sign-in-page
|
||||
// fallback is deliberately not used: pointing someone who is
|
||||
// already signed in at the login screen helps nobody.
|
||||
$continue = $this->continueUrl( $this->successPageId( $atts ) );
|
||||
$link = null === $continue
|
||||
? ''
|
||||
: '<p><a href="' . esc_url( $continue ) . '">'
|
||||
. esc_html__( 'Continue to your account', 'unsupervised-schedular' )
|
||||
. '</a></p>';
|
||||
// Both logged-in outcomes are dead ends without somewhere to go next,
|
||||
// so both offer the same "continue" link to the configured page.
|
||||
wp_enqueue_style( 'us-scheduler' );
|
||||
$link = $this->continueLink( $atts );
|
||||
|
||||
if ( self::RESULT_INVITE === $registered ) {
|
||||
// An invited student is done the moment they land here logged in.
|
||||
return '<div class="us-register-form"><p class="us-success">'
|
||||
. esc_html__( 'Your account has been created and you are now logged in.', 'unsupervised-schedular' )
|
||||
. '</p>' . $link . '</div>';
|
||||
}
|
||||
|
||||
return '<p>' . esc_html__( 'You already have an account and are logged in.', 'unsupervised-schedular' ) . '</p>';
|
||||
return '<div class="us-register-form"><p>'
|
||||
. esc_html__( 'You already have an account and are logged in.', 'unsupervised-schedular' )
|
||||
. '</p>' . $link . '</div>';
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- token identifies the invite; the form submit is nonce-checked in maybeHandleSubmit.
|
||||
@@ -353,6 +350,26 @@ class RegistrationPage {
|
||||
return $this->continueUrl( $loginPageId ) ?? wp_login_url();
|
||||
}
|
||||
|
||||
/**
|
||||
* The "continue to your account" paragraph shown to a logged-in visitor, or
|
||||
* an empty string when no destination page is configured.
|
||||
*
|
||||
* The sign-in-page fallback {@see loginUrl()} applies is deliberately not
|
||||
* used here: pointing someone who is already signed in at the login screen is
|
||||
* the same dead end with extra steps, so no link is better than that one.
|
||||
*
|
||||
* @param array<int|string, mixed> $atts
|
||||
*/
|
||||
private function continueLink( array $atts ): string {
|
||||
$continue = $this->continueUrl( $this->successPageId( $atts ) );
|
||||
|
||||
return null === $continue
|
||||
? ''
|
||||
: '<p><a href="' . esc_url( $continue ) . '">'
|
||||
. esc_html__( 'Continue to your account', 'unsupervised-schedular' )
|
||||
. '</a></p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* The chosen post-registration page's URL, or null when none is configured
|
||||
* (or it has since been deleted). Unlike {@see loginUrl()} this has no
|
||||
|
||||
Reference in New Issue
Block a user