Skip to content
This repository was archived by the owner on Nov 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/js/google-signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
type: 'standard',
theme: 'outline',
size: 'large',
text: 'continue_with',
text: container.dataset.googleText || 'continue_with',
shape: 'rectangular',
logo_alignment: 'left',
width: 300
Expand Down
2 changes: 1 addition & 1 deletion blocks/login-register/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
// origins not pre-registered in GCP).
$google_signin_redirect_url = null;
if ( $google_oauth_enabled && ! $google_is_canonical && function_exists( 'ec_users_canonical_google_signin_url' ) ) {
$google_signin_redirect_url = ec_users_canonical_google_signin_url( $success_redirect );
$google_signin_redirect_url = ec_users_canonical_google_signin_url( $success_redirect, $from_join );
}

$config = array(
Expand Down
13 changes: 8 additions & 5 deletions blocks/login-register/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { createRoot } from 'react-dom/client';
import { BlockShell, BlockShellHeader, BlockShellInner, Panel, ResponsiveTabs } from '@extrachill/components';
import '@extrachill/components/styles/components.scss';

function GoogleButtons( { redirectUrl } ) {
export function GoogleButtons( { redirectUrl, registration = false } ) {
const buttonLabel = registration ? 'Sign up with Google' : 'Continue with Google';
const googleText = registration ? 'signup_with' : 'continue_with';

// When redirectUrl is set, this subsite is NOT the canonical Google
// origin — render a styled link that sends the user to the canonical
// login page instead of trying to render the GIS button here (which
Expand All @@ -33,10 +36,10 @@ function GoogleButtons( { redirectUrl } ) {
<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"/>
</svg>
</span>
<span className="google-signin-button__label">Continue with Google</span>
<span className="google-signin-button__label">{ buttonLabel }</span>
</a>
) : (
<div className="google-signin-button"></div>
<div className="google-signin-button" data-google-text={ googleText }></div>
) }
</div>
</>
Expand Down Expand Up @@ -247,7 +250,7 @@ export function LoginPanel( { config, notice, setNotice } ) {
);
}

function RegisterPanel( { config, notice, setNotice } ) {
export function RegisterPanel( { config, notice, setNotice } ) {
const panelRef = useRef( null );

useEffect( () => {
Expand Down Expand Up @@ -359,7 +362,7 @@ function RegisterPanel( { config, notice, setNotice } ) {
</div>
<div className="login-register-turnstile" dangerouslySetInnerHTML={ { __html: config.turnstileHtml } } />
</form>
{ config.googleOAuthEnabled && <GoogleButtons redirectUrl={ config.googleSignInRedirectUrl } /> }
{ config.googleOAuthEnabled && <GoogleButtons redirectUrl={ config.googleSignInRedirectUrl } registration={ true } /> }
</div>
</Panel>
);
Expand Down
1 change: 1 addition & 0 deletions extrachill-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function extrachill_users_init() {
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/core/local-scene-migration.php';
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/core/orphan-meta-cleanup.php';

require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/auth/registration-redirect.php';
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/auth/login.php';
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/auth/core-signup.php';
require_once EXTRACHILL_USERS_PLUGIN_DIR . 'inc/auth/register.php';
Expand Down
14 changes: 7 additions & 7 deletions inc/auth-tokens/service.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ function extrachill_users_login_with_tokens( string $identifier, string $passwor
/**
* Register service: validates, creates user, optionally sets cookies, and returns tokens.
*
* User is created with auto-generated username and must complete onboarding
* to set final username and artist/professional flags.
* User is created with an auto-generated username. Ordinary registrations can
* participate immediately and customize their profile later; /join still
* requires artist/professional onboarding.
*
* EC policy (Turnstile, invite redemption, onboarding redirect fields,
* community provisioning) is enforced here; token minting is delegated to the
Expand Down Expand Up @@ -471,7 +472,7 @@ function extrachill_users_register_with_tokens( array $payload ) {

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

if ( ! empty( $success_redirect_url ) ) {
if ( $from_join && ! empty( $success_redirect_url ) ) {
update_user_meta( (int) $user_id, 'onboarding_redirect_url', $success_redirect_url );
}

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

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

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

$response = array(
'access_token' => $tokens['access']['token'],
'access_expires_at' => gmdate( 'c', (int) $tokens['access']['expires_at'] ),
'refresh_token' => $tokens['refresh']['token'],
'refresh_expires_at' => gmdate( 'c', (int) $tokens['refresh']['expires_at'] ),
'onboarding_completed' => false,
'redirect_url' => $onboarding_url,
'redirect_url' => $redirect_url,
'user' => extrachill_users_token_user_payload( $user ),
);

Expand Down
14 changes: 7 additions & 7 deletions inc/auth/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function extrachill_handle_registration() {
add_action( 'admin_post_extrachill_register_user', 'extrachill_handle_registration' );

/**
* Auto-login user after registration and redirect to onboarding.
* Auto-login user after registration and resume the requested destination.
*
* @param int $user_id User ID.
* @param EC_Redirect_Handler $redirect Redirect handler instance.
Expand Down Expand Up @@ -341,21 +341,21 @@ function extrachill_auto_login_new_user( int $user_id, EC_Redirect_Handler $redi
$final_redirect_url = $success_redirect_url;
}

if ( ! empty( $final_redirect_url ) ) {
$from_join = function_exists( 'ec_is_onboarding_from_join' ) && ec_is_onboarding_from_join( $user_id );
if ( $from_join && ! empty( $final_redirect_url ) ) {
update_user_meta( $user_id, 'onboarding_redirect_url', $final_redirect_url );
}

$onboarding_url = function_exists( 'ec_get_site_url' )
? ec_get_site_url( 'community' ) . '/onboarding/'
: home_url( '/onboarding/' );
$account_created_token = wp_create_nonce( 'ec_account_created' );
$redirect_url = ec_users_post_registration_redirect_url( $from_join, false, $final_redirect_url, $account_created_token );
if ( $invitation_outcome ) {
$query_args = array( 'artist_invitation' => $invitation_outcome['status'] );
if ( ! empty( $invitation_outcome['error'] ) ) {
$query_args['artist_invitation_error'] = $invitation_outcome['error']['code'];
$query_args['artist_invitation_error_status'] = $invitation_outcome['error']['status'];
}
$onboarding_url = add_query_arg( $query_args, $onboarding_url );
$redirect_url = add_query_arg( $query_args, $redirect_url );
}

$redirect->redirect_to( $onboarding_url );
$redirect->redirect_to( $redirect_url );
}
87 changes: 87 additions & 0 deletions inc/auth/registration-redirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* Progressive post-registration redirects.
*
* @package ExtraChill\Users
*/

defined( 'ABSPATH' ) || exit;

/**
* One-time query marker used to show account-creation confirmation.
*/
const EC_USERS_ACCOUNT_CREATED_PARAM = 'ec_account_created';

/**
* Resolve the destination after account creation.
*
* Artist/professional join requests still require onboarding. Ordinary account
* creation returns visitors to the Extra Chill feature that prompted registration
* so profile customization can happen later.
*
* @param bool $from_join Whether the request came from /join.
* @param bool $onboarding_completed Whether profile onboarding is complete.
* @param string $success_redirect_url Requested post-registration destination.
* @param string $account_created_token Signed one-time confirmation token.
* @return string Safe post-registration destination.
*/
function ec_users_post_registration_redirect_url( $from_join, $onboarding_completed, $success_redirect_url, $account_created_token = '' ) {
if ( $from_join && ! $onboarding_completed ) {
$redirect_url = function_exists( 'ec_get_site_url' )
? ec_get_site_url( 'community' ) . '/onboarding/'
: home_url( '/onboarding/' );
} elseif ( '' !== (string) $success_redirect_url
&& function_exists( 'ec_users_is_valid_return_to_url' )
&& ec_users_is_valid_return_to_url( $success_redirect_url ) ) {
$redirect_url = $from_join
? add_query_arg( 'from_join', 'true', (string) $success_redirect_url )
: (string) $success_redirect_url;
} else {
$redirect_url = function_exists( 'ec_get_site_url' )
? ec_get_site_url( 'community' )
: home_url();
}

return '' !== $account_created_token
? add_query_arg( EC_USERS_ACCOUNT_CREATED_PARAM, $account_created_token, $redirect_url )
: $redirect_url;
}

/**
* Show a one-time confirmation after registration creates an account.
*
* Removing the signed marker through a same-page redirect prevents refreshes
* from repeating the notice while preserving feature-specific query parameters.
*/
function ec_users_handle_account_created_notice() {
if ( ! is_user_logged_in() || ! isset( $_GET[ EC_USERS_ACCOUNT_CREATED_PARAM ] ) ) {
return;
}

$notice_nonce = sanitize_text_field( wp_unslash( $_GET[ EC_USERS_ACCOUNT_CREATED_PARAM ] ) );
if ( ! wp_verify_nonce( $notice_nonce, 'ec_account_created' ) ) {
return;
}

if ( function_exists( 'extrachill_set_notice' ) ) {
$args = array();
if ( function_exists( 'ec_get_site_url' ) ) {
$args['actions'] = array(
array(
'label' => __( 'Customize Your Profile', 'extrachill-users' ),
'url' => ec_get_site_url( 'community' ) . '/settings/',
),
);
}

extrachill_set_notice(
__( "You're in! Your Extra Chill account is ready. Set up your profile whenever you have time.", 'extrachill-users' ),
'success',
$args
);
}

wp_safe_redirect( remove_query_arg( EC_USERS_ACCOUNT_CREATED_PARAM ) );
exit;
}
add_action( 'template_redirect', 'ec_users_handle_account_created_notice', 1 );
28 changes: 0 additions & 28 deletions inc/core/abilities/user-profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,6 @@ function extrachill_users_get_link_types() {
);
}

/**
* Require the authenticated user to finish the onboarding lifecycle.
*
* @param int $user_id User ID.
* @return true|WP_Error True when eligible, otherwise an onboarding error.
*/
function extrachill_users_require_completed_onboarding( $user_id ) {
if ( ec_is_onboarding_complete( $user_id ) ) {
return true;
}

return new WP_Error(
'onboarding_incomplete',
__( 'Complete onboarding before updating your public profile.', 'extrachill-users' ),
array( 'status' => 403 )
);
}

/**
* Get user profile data.
*
Expand Down Expand Up @@ -255,11 +237,6 @@ function extrachill_users_ability_update_profile( $input ) {
return $user_id;
}

$onboarding = extrachill_users_require_completed_onboarding( $user_id );
if ( is_wp_error( $onboarding ) ) {
return $onboarding;
}

$user = get_user_by( 'ID', $user_id );
if ( ! $user ) {
return new WP_Error( 'user_not_found', 'User not found.' );
Expand Down Expand Up @@ -321,11 +298,6 @@ function extrachill_users_ability_update_links( $input ) {
return $user_id;
}

$onboarding = extrachill_users_require_completed_onboarding( $user_id );
if ( is_wp_error( $onboarding ) ) {
return $onboarding;
}

$links = isset( $input['links'] ) ? $input['links'] : array();

$user = get_user_by( 'ID', $user_id );
Expand Down
33 changes: 17 additions & 16 deletions inc/core/registration-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function extrachill_notify_admin_new_user( $user_id, $registration_page, $regist
$body_html .= '<strong>Registration Source:</strong> ' . esc_html( $source_label ) . ' (' . esc_html( $method_label ) . ')<br>';
$body_html .= '<strong>Registration Page:</strong> ' . esc_html( $page_display ) . '</p>';
$body_html .= '<p><a href="' . esc_url( $edit_url ) . '">Edit user in admin</a></p>';
$body_html .= '<p><em>Note: User has not yet completed onboarding — profile URL not available until username is chosen.</em></p>';
$body_html .= '<p><em>Note: User has not yet customized their profile.</em></p>';

$result = extrachill_send_registration_email(
array(
Expand Down Expand Up @@ -226,25 +226,26 @@ function extrachill_send_welcome_email_complete( $user_data ) {
/**
* Send welcome email for users who haven't completed onboarding.
*
* Encourages user to complete their account setup.
* Encourages optional profile customization after account creation.
*
* @param WP_User $user_data User data object.
* @return bool True if email sent successfully.
*/
function extrachill_send_welcome_email_incomplete( $user_data ) {
$email = $user_data->user_email;
$reset_pass_link = ec_get_site_url( 'community' ) . '/reset-password/';
$onboarding_url = ec_get_site_url( 'community' ) . '/onboarding/';
$email = $user_data->user_email;
$profile_url = ec_get_site_url( 'community' ) . '/settings/';
$community_url = ec_get_site_url( 'community' );

$subject = 'Complete Your Extra Chill Account Setup!';
$subject = 'Your Extra Chill account is ready';

$body_html = "<p>Welcome to <strong>Extra Chill</strong>! You're almost ready to join the community.</p>";
$body_html .= '<p><strong><a href="' . esc_url( $onboarding_url ) . '">Complete your account setup</a></strong> to choose your username and get started.</p>';
$body_html .= '<p>Once set up, you can participate in community discussions, comment on posts, and follow your favorite artists.</p>';
$body_html .= '<p><strong>Account Details:</strong><br>';
$body_html .= 'Email: <strong>' . esc_html( $email ) . '</strong><br>';
$body_html .= 'If you forget your password, you can reset it <a href="' . esc_url( $reset_pass_link ) . '">here</a>.</p>';
$body_html .= '<p>See you around!</p>';
$body_html = '<p>Welcome to <strong>Extra Chill</strong>! Your account is ready, and you can jump in whenever you want.</p>';
$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>';
$body_html .= '<p>Your account lets you:</p>';
$body_html .= '<ul><li>Join community discussions and comment on stories</li>';
$body_html .= '<li>Track concerts and see who else is going</li>';
$body_html .= '<li>Follow artists and keep up with notifications</li>';
$body_html .= '<li>Explore artist and music-industry tools</li></ul>';
$body_html .= '<p><a href="' . esc_url( $community_url ) . '">Visit the Extra Chill Community</a> anytime.</p>';
$body_html .= '<p>Much love,<br>Extra Chill</p>';

$result = extrachill_send_registration_email(
Expand All @@ -255,9 +256,9 @@ function extrachill_send_welcome_email_incomplete( $user_data ) {
'context' => array(
'subject_html' => esc_html( $subject ),
'body_html' => $body_html,
'cta_url' => $onboarding_url,
'cta_label' => 'Complete Your Account Setup',
'preheader' => 'Finish setting up your Extra Chill account.',
'cta_url' => $profile_url,
'cta_label' => 'Customize Your Profile',
'preheader' => 'Your account is ready. Make your profile yours whenever you have time.',
),
)
);
Expand Down
18 changes: 12 additions & 6 deletions inc/oauth/google-canonical-origin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,27 @@ function ec_users_is_canonical_google_origin() {
* @param string $return_to The URL to send the user to after sign-in
* (must pass ec_users_is_valid_return_to_url()
* to be honored by the canonical origin).
* @param bool $from_join Whether artist/professional onboarding is required.
* @return string The canonical login URL.
*/
function ec_users_canonical_google_signin_url( $return_to ) {
function ec_users_canonical_google_signin_url( $return_to, $from_join = false ) {
$base = function_exists( 'ec_get_site_url' )
? ec_get_site_url( 'community' ) . '/login/'
: home_url( '/login/' );

if ( '' === (string) $return_to ) {
$args = array();
if ( '' !== (string) $return_to ) {
$args[ EC_USERS_GOOGLE_REDIRECT_PARAM ] = rawurlencode( $return_to );
}
if ( $from_join ) {
$args['from_join'] = 'true';
}

if ( empty( $args ) ) {
return $base;
}

return add_query_arg(
array( EC_USERS_GOOGLE_REDIRECT_PARAM => rawurlencode( $return_to ) ),
$base
);
return add_query_arg( $args, $base );
}

/**
Expand Down
Loading