Skip to content
This repository was archived by the owner on Nov 2, 2026. It is now read-only.

Commit db4987f

Browse files
authored
Merge pull request #275 from Extra-Chill/feat/273-instant-google-registration
feat: make registration progressive
2 parents 68e1b7c + 8225e40 commit db4987f

16 files changed

Lines changed: 325 additions & 101 deletions

‎assets/js/google-signin.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
type: 'standard',
7676
theme: 'outline',
7777
size: 'large',
78-
text: 'continue_with',
78+
text: container.dataset.googleText || 'continue_with',
7979
shape: 'rectangular',
8080
logo_alignment: 'left',
8181
width: 300

‎blocks/login-register/render.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
// origins not pre-registered in GCP).
135135
$google_signin_redirect_url = null;
136136
if ( $google_oauth_enabled && ! $google_is_canonical && function_exists( 'ec_users_canonical_google_signin_url' ) ) {
137-
$google_signin_redirect_url = ec_users_canonical_google_signin_url( $success_redirect );
137+
$google_signin_redirect_url = ec_users_canonical_google_signin_url( $success_redirect, $from_join );
138138
}
139139

140140
$config = array(

‎blocks/login-register/view.js‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { createRoot } from 'react-dom/client';
66
import { BlockShell, BlockShellHeader, BlockShellInner, Panel, ResponsiveTabs } from '@extrachill/components';
77
import '@extrachill/components/styles/components.scss';
88

9-
function GoogleButtons( { redirectUrl } ) {
9+
export function GoogleButtons( { redirectUrl, registration = false } ) {
10+
const buttonLabel = registration ? 'Sign up with Google' : 'Continue with Google';
11+
const googleText = registration ? 'signup_with' : 'continue_with';
12+
1013
// When redirectUrl is set, this subsite is NOT the canonical Google
1114
// origin — render a styled link that sends the user to the canonical
1215
// login page instead of trying to render the GIS button here (which
@@ -33,10 +36,10 @@ function GoogleButtons( { redirectUrl } ) {
3336
<path d="M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 00.957 4.958L3.964 7.29C4.672 5.163 6.656 3.58 9 3.58z" fill="#EA4335"/>
3437
</svg>
3538
</span>
36-
<span className="google-signin-button__label">Continue with Google</span>
39+
<span className="google-signin-button__label">{ buttonLabel }</span>
3740
</a>
3841
) : (
39-
<div className="google-signin-button"></div>
42+
<div className="google-signin-button" data-google-text={ googleText }></div>
4043
) }
4144
</div>
4245
</>
@@ -247,7 +250,7 @@ export function LoginPanel( { config, notice, setNotice } ) {
247250
);
248251
}
249252

250-
function RegisterPanel( { config, notice, setNotice } ) {
253+
export function RegisterPanel( { config, notice, setNotice } ) {
251254
const panelRef = useRef( null );
252255

253256
useEffect( () => {
@@ -359,7 +362,7 @@ function RegisterPanel( { config, notice, setNotice } ) {
359362
</div>
360363
<div className="login-register-turnstile" dangerouslySetInnerHTML={ { __html: config.turnstileHtml } } />
361364
</form>
362-
{ config.googleOAuthEnabled && <GoogleButtons redirectUrl={ config.googleSignInRedirectUrl } /> }
365+
{ config.googleOAuthEnabled && <GoogleButtons redirectUrl={ config.googleSignInRedirectUrl } registration={ true } /> }
363366
</div>
364367
</Panel>
365368
);

‎extrachill-users.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function extrachill_users_init() {
116116
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/core/local-scene-migration.php';
117117
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/core/orphan-meta-cleanup.php';
118118

119+
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/auth/registration-redirect.php';
119120
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/auth/login.php';
120121
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/auth/core-signup.php';
121122
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/auth/register.php';

‎inc/auth-tokens/service.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ function extrachill_users_login_with_tokens( string $identifier, string $passwor
304304
/**
305305
* Register service: validates, creates user, optionally sets cookies, and returns tokens.
306306
*
307-
* User is created with auto-generated username and must complete onboarding
308-
* to set final username and artist/professional flags.
307+
* User is created with an auto-generated username. Ordinary registrations can
308+
* participate immediately and customize their profile later; /join still
309+
* requires artist/professional onboarding.
309310
*
310311
* EC policy (Turnstile, invite redemption, onboarding redirect fields,
311312
* community provisioning) is enforced here; token minting is delegated to the
@@ -471,7 +472,7 @@ function extrachill_users_register_with_tokens( array $payload ) {
471472

472473
update_user_meta( (int) $user_id, 'registration_timestamp', current_time( 'mysql' ) );
473474

474-
if ( ! empty( $success_redirect_url ) ) {
475+
if ( $from_join && ! empty( $success_redirect_url ) ) {
475476
update_user_meta( (int) $user_id, 'onboarding_redirect_url', $success_redirect_url );
476477
}
477478

@@ -519,17 +520,16 @@ function extrachill_users_register_with_tokens( array $payload ) {
519520

520521
$tokens = extrachill_users_mint_token_pair( (int) $user_id, $device_id, $device_name );
521522

522-
$onboarding_url = function_exists( 'ec_get_site_url' )
523-
? ec_get_site_url( 'community' ) . '/onboarding/'
524-
: home_url( '/onboarding/' );
523+
$account_created_token = $set_cookie ? wp_create_nonce( 'ec_account_created' ) : '';
524+
$redirect_url = ec_users_post_registration_redirect_url( $from_join, false, $success_redirect_url, $account_created_token );
525525

526526
$response = array(
527527
'access_token' => $tokens['access']['token'],
528528
'access_expires_at' => gmdate( 'c', (int) $tokens['access']['expires_at'] ),
529529
'refresh_token' => $tokens['refresh']['token'],
530530
'refresh_expires_at' => gmdate( 'c', (int) $tokens['refresh']['expires_at'] ),
531531
'onboarding_completed' => false,
532-
'redirect_url' => $onboarding_url,
532+
'redirect_url' => $redirect_url,
533533
'user' => extrachill_users_token_user_payload( $user ),
534534
);
535535

‎inc/auth/register.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function extrachill_handle_registration() {
309309
add_action( 'admin_post_extrachill_register_user', 'extrachill_handle_registration' );
310310

311311
/**
312-
* Auto-login user after registration and redirect to onboarding.
312+
* Auto-login user after registration and resume the requested destination.
313313
*
314314
* @param int $user_id User ID.
315315
* @param EC_Redirect_Handler $redirect Redirect handler instance.
@@ -341,21 +341,21 @@ function extrachill_auto_login_new_user( int $user_id, EC_Redirect_Handler $redi
341341
$final_redirect_url = $success_redirect_url;
342342
}
343343

344-
if ( ! empty( $final_redirect_url ) ) {
344+
$from_join = function_exists( 'ec_is_onboarding_from_join' ) && ec_is_onboarding_from_join( $user_id );
345+
if ( $from_join && ! empty( $final_redirect_url ) ) {
345346
update_user_meta( $user_id, 'onboarding_redirect_url', $final_redirect_url );
346347
}
347348

348-
$onboarding_url = function_exists( 'ec_get_site_url' )
349-
? ec_get_site_url( 'community' ) . '/onboarding/'
350-
: home_url( '/onboarding/' );
349+
$account_created_token = wp_create_nonce( 'ec_account_created' );
350+
$redirect_url = ec_users_post_registration_redirect_url( $from_join, false, $final_redirect_url, $account_created_token );
351351
if ( $invitation_outcome ) {
352352
$query_args = array( 'artist_invitation' => $invitation_outcome['status'] );
353353
if ( ! empty( $invitation_outcome['error'] ) ) {
354354
$query_args['artist_invitation_error'] = $invitation_outcome['error']['code'];
355355
$query_args['artist_invitation_error_status'] = $invitation_outcome['error']['status'];
356356
}
357-
$onboarding_url = add_query_arg( $query_args, $onboarding_url );
357+
$redirect_url = add_query_arg( $query_args, $redirect_url );
358358
}
359359

360-
$redirect->redirect_to( $onboarding_url );
360+
$redirect->redirect_to( $redirect_url );
361361
}

‎inc/auth/registration-redirect.php‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Progressive post-registration redirects.
4+
*
5+
* @package ExtraChill\Users
6+
*/
7+
8+
defined( 'ABSPATH' ) || exit;
9+
10+
/**
11+
* One-time query marker used to show account-creation confirmation.
12+
*/
13+
const EC_USERS_ACCOUNT_CREATED_PARAM = 'ec_account_created';
14+
15+
/**
16+
* Resolve the destination after account creation.
17+
*
18+
* Artist/professional join requests still require onboarding. Ordinary account
19+
* creation returns visitors to the Extra Chill feature that prompted registration
20+
* so profile customization can happen later.
21+
*
22+
* @param bool $from_join Whether the request came from /join.
23+
* @param bool $onboarding_completed Whether profile onboarding is complete.
24+
* @param string $success_redirect_url Requested post-registration destination.
25+
* @param string $account_created_token Signed one-time confirmation token.
26+
* @return string Safe post-registration destination.
27+
*/
28+
function ec_users_post_registration_redirect_url( $from_join, $onboarding_completed, $success_redirect_url, $account_created_token = '' ) {
29+
if ( $from_join && ! $onboarding_completed ) {
30+
$redirect_url = function_exists( 'ec_get_site_url' )
31+
? ec_get_site_url( 'community' ) . '/onboarding/'
32+
: home_url( '/onboarding/' );
33+
} elseif ( '' !== (string) $success_redirect_url
34+
&& function_exists( 'ec_users_is_valid_return_to_url' )
35+
&& ec_users_is_valid_return_to_url( $success_redirect_url ) ) {
36+
$redirect_url = $from_join
37+
? add_query_arg( 'from_join', 'true', (string) $success_redirect_url )
38+
: (string) $success_redirect_url;
39+
} else {
40+
$redirect_url = function_exists( 'ec_get_site_url' )
41+
? ec_get_site_url( 'community' )
42+
: home_url();
43+
}
44+
45+
return '' !== $account_created_token
46+
? add_query_arg( EC_USERS_ACCOUNT_CREATED_PARAM, $account_created_token, $redirect_url )
47+
: $redirect_url;
48+
}
49+
50+
/**
51+
* Show a one-time confirmation after registration creates an account.
52+
*
53+
* Removing the signed marker through a same-page redirect prevents refreshes
54+
* from repeating the notice while preserving feature-specific query parameters.
55+
*/
56+
function ec_users_handle_account_created_notice() {
57+
if ( ! is_user_logged_in() || ! isset( $_GET[ EC_USERS_ACCOUNT_CREATED_PARAM ] ) ) {
58+
return;
59+
}
60+
61+
$notice_nonce = sanitize_text_field( wp_unslash( $_GET[ EC_USERS_ACCOUNT_CREATED_PARAM ] ) );
62+
if ( ! wp_verify_nonce( $notice_nonce, 'ec_account_created' ) ) {
63+
return;
64+
}
65+
66+
if ( function_exists( 'extrachill_set_notice' ) ) {
67+
$args = array();
68+
if ( function_exists( 'ec_get_site_url' ) ) {
69+
$args['actions'] = array(
70+
array(
71+
'label' => __( 'Customize Your Profile', 'extrachill-users' ),
72+
'url' => ec_get_site_url( 'community' ) . '/settings/',
73+
),
74+
);
75+
}
76+
77+
extrachill_set_notice(
78+
__( "You're in! Your Extra Chill account is ready. Set up your profile whenever you have time.", 'extrachill-users' ),
79+
'success',
80+
$args
81+
);
82+
}
83+
84+
wp_safe_redirect( remove_query_arg( EC_USERS_ACCOUNT_CREATED_PARAM ) );
85+
exit;
86+
}
87+
add_action( 'template_redirect', 'ec_users_handle_account_created_notice', 1 );

‎inc/core/abilities/user-profile.php‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,6 @@ function extrachill_users_get_link_types() {
140140
);
141141
}
142142

143-
/**
144-
* Require the authenticated user to finish the onboarding lifecycle.
145-
*
146-
* @param int $user_id User ID.
147-
* @return true|WP_Error True when eligible, otherwise an onboarding error.
148-
*/
149-
function extrachill_users_require_completed_onboarding( $user_id ) {
150-
if ( ec_is_onboarding_complete( $user_id ) ) {
151-
return true;
152-
}
153-
154-
return new WP_Error(
155-
'onboarding_incomplete',
156-
__( 'Complete onboarding before updating your public profile.', 'extrachill-users' ),
157-
array( 'status' => 403 )
158-
);
159-
}
160-
161143
/**
162144
* Get user profile data.
163145
*
@@ -255,11 +237,6 @@ function extrachill_users_ability_update_profile( $input ) {
255237
return $user_id;
256238
}
257239

258-
$onboarding = extrachill_users_require_completed_onboarding( $user_id );
259-
if ( is_wp_error( $onboarding ) ) {
260-
return $onboarding;
261-
}
262-
263240
$user = get_user_by( 'ID', $user_id );
264241
if ( ! $user ) {
265242
return new WP_Error( 'user_not_found', 'User not found.' );
@@ -321,11 +298,6 @@ function extrachill_users_ability_update_links( $input ) {
321298
return $user_id;
322299
}
323300

324-
$onboarding = extrachill_users_require_completed_onboarding( $user_id );
325-
if ( is_wp_error( $onboarding ) ) {
326-
return $onboarding;
327-
}
328-
329301
$links = isset( $input['links'] ) ? $input['links'] : array();
330302

331303
$user = get_user_by( 'ID', $user_id );

‎inc/core/registration-emails.php‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function extrachill_notify_admin_new_user( $user_id, $registration_page, $regist
9292
$body_html .= '<strong>Registration Source:</strong> ' . esc_html( $source_label ) . ' (' . esc_html( $method_label ) . ')<br>';
9393
$body_html .= '<strong>Registration Page:</strong> ' . esc_html( $page_display ) . '</p>';
9494
$body_html .= '<p><a href="' . esc_url( $edit_url ) . '">Edit user in admin</a></p>';
95-
$body_html .= '<p><em>Note: User has not yet completed onboarding — profile URL not available until username is chosen.</em></p>';
95+
$body_html .= '<p><em>Note: User has not yet customized their profile.</em></p>';
9696

9797
$result = extrachill_send_registration_email(
9898
array(
@@ -226,25 +226,26 @@ function extrachill_send_welcome_email_complete( $user_data ) {
226226
/**
227227
* Send welcome email for users who haven't completed onboarding.
228228
*
229-
* Encourages user to complete their account setup.
229+
* Encourages optional profile customization after account creation.
230230
*
231231
* @param WP_User $user_data User data object.
232232
* @return bool True if email sent successfully.
233233
*/
234234
function extrachill_send_welcome_email_incomplete( $user_data ) {
235-
$email = $user_data->user_email;
236-
$reset_pass_link = ec_get_site_url( 'community' ) . '/reset-password/';
237-
$onboarding_url = ec_get_site_url( 'community' ) . '/onboarding/';
235+
$email = $user_data->user_email;
236+
$profile_url = ec_get_site_url( 'community' ) . '/settings/';
237+
$community_url = ec_get_site_url( 'community' );
238238

239-
$subject = 'Complete Your Extra Chill Account Setup!';
239+
$subject = 'Your Extra Chill account is ready';
240240

241-
$body_html = "<p>Welcome to <strong>Extra Chill</strong>! You're almost ready to join the community.</p>";
242-
$body_html .= '<p><strong><a href="' . esc_url( $onboarding_url ) . '">Complete your account setup</a></strong> to choose your username and get started.</p>';
243-
$body_html .= '<p>Once set up, you can participate in community discussions, comment on posts, and follow your favorite artists.</p>';
244-
$body_html .= '<p><strong>Account Details:</strong><br>';
245-
$body_html .= 'Email: <strong>' . esc_html( $email ) . '</strong><br>';
246-
$body_html .= 'If you forget your password, you can reset it <a href="' . esc_url( $reset_pass_link ) . '">here</a>.</p>';
247-
$body_html .= '<p>See you around!</p>';
241+
$body_html = '<p>Welcome to <strong>Extra Chill</strong>! Your account is ready, and you can jump in whenever you want.</p>';
242+
$body_html .= '<p><strong>Make your profile yours</strong> by adding a photo, bio, links, username, and local scene. You can do that now or come back to it later.</p>';
243+
$body_html .= '<p>Your account lets you:</p>';
244+
$body_html .= '<ul><li>Join community discussions and comment on stories</li>';
245+
$body_html .= '<li>Track concerts and see who else is going</li>';
246+
$body_html .= '<li>Follow artists and keep up with notifications</li>';
247+
$body_html .= '<li>Explore artist and music-industry tools</li></ul>';
248+
$body_html .= '<p><a href="' . esc_url( $community_url ) . '">Visit the Extra Chill Community</a> anytime.</p>';
248249
$body_html .= '<p>Much love,<br>Extra Chill</p>';
249250

250251
$result = extrachill_send_registration_email(
@@ -255,9 +256,9 @@ function extrachill_send_welcome_email_incomplete( $user_data ) {
255256
'context' => array(
256257
'subject_html' => esc_html( $subject ),
257258
'body_html' => $body_html,
258-
'cta_url' => $onboarding_url,
259-
'cta_label' => 'Complete Your Account Setup',
260-
'preheader' => 'Finish setting up your Extra Chill account.',
259+
'cta_url' => $profile_url,
260+
'cta_label' => 'Customize Your Profile',
261+
'preheader' => 'Your account is ready. Make your profile yours whenever you have time.',
261262
),
262263
)
263264
);

‎inc/oauth/google-canonical-origin.php‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,27 @@ function ec_users_is_canonical_google_origin() {
6666
* @param string $return_to The URL to send the user to after sign-in
6767
* (must pass ec_users_is_valid_return_to_url()
6868
* to be honored by the canonical origin).
69+
* @param bool $from_join Whether artist/professional onboarding is required.
6970
* @return string The canonical login URL.
7071
*/
71-
function ec_users_canonical_google_signin_url( $return_to ) {
72+
function ec_users_canonical_google_signin_url( $return_to, $from_join = false ) {
7273
$base = function_exists( 'ec_get_site_url' )
7374
? ec_get_site_url( 'community' ) . '/login/'
7475
: home_url( '/login/' );
7576

76-
if ( '' === (string) $return_to ) {
77+
$args = array();
78+
if ( '' !== (string) $return_to ) {
79+
$args[ EC_USERS_GOOGLE_REDIRECT_PARAM ] = rawurlencode( $return_to );
80+
}
81+
if ( $from_join ) {
82+
$args['from_join'] = 'true';
83+
}
84+
85+
if ( empty( $args ) ) {
7786
return $base;
7887
}
7988

80-
return add_query_arg(
81-
array( EC_USERS_GOOGLE_REDIRECT_PARAM => rawurlencode( $return_to ) ),
82-
$base
83-
);
89+
return add_query_arg( $args, $base );
8490
}
8591

8692
/**

0 commit comments

Comments
 (0)