From 1215b557b27335e504b45ac86f22cf8e123a3c53 Mon Sep 17 00:00:00 2001 From: DustyReagan Date: Mon, 13 May 2024 14:44:26 -0500 Subject: [PATCH] Check user is connected to wpcom --- .../calypso-locale-sync/calypso-locale-sync.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/projects/packages/jetpack-mu-wpcom/src/features/calypso-locale-sync/calypso-locale-sync.php b/projects/packages/jetpack-mu-wpcom/src/features/calypso-locale-sync/calypso-locale-sync.php index 372c45366f31b..40ac7e72e30b8 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/calypso-locale-sync/calypso-locale-sync.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/calypso-locale-sync/calypso-locale-sync.php @@ -6,21 +6,23 @@ */ use Automattic\Jetpack\Connection\Client; +use Automattic\Jetpack\Connection\Manager as Connection_Manager; if ( function_exists( 'wpcom_is_nav_redesign_enabled' ) && wpcom_is_nav_redesign_enabled() ) { add_filter( 'insert_user_meta', function ( $meta, $user, $update ) { - $locale = $meta['locale']; - $old_locale = get_user_locale( $user ); + $locale = $meta['locale']; + $old_locale = get_user_locale( $user ); + $is_user_connected = ( new Connection_Manager( 'jetpack' ) )->is_user_connected(); - if ( ! $update || $old_locale === $locale ) { - // Only for locale changes on an existing user + if ( ! $update || $old_locale === $locale || ! $is_user_connected ) { + // Only proceed for locale changes on an existing connected WPCOM user. return $meta; } if ( ! $locale ) { - // No locale means the "Site Default" option which is the Site language (WPLANG). + // No locale means the "Site Default" option, which is the Site language (WPLANG). $locale = get_option( 'WPLANG', '' ); }