Skip to content

Commit

Permalink
Change hook to check for locale updates
Browse files Browse the repository at this point in the history
  • Loading branch information
miksansegundo committed May 13, 2024
1 parent 2a11689 commit 5120209
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

if ( function_exists( 'wpcom_is_nav_redesign_enabled' ) && wpcom_is_nav_redesign_enabled() ) {
add_filter(
'profile_update',
function ( $user_id, $old_user_data, $user_data ) {
$locale = $user_data['locale'];
$old_locale = $old_user_data['locale'];
'insert_user_meta',
function ( $meta, $user, $update ) {
$locale = $meta['locale'];
$old_locale = get_user_locale( $user );

if ( $locale && $old_locale === $locale ) {
// No locale changes
return;
if ( ! $update || $old_locale === $locale ) {
// Only for locale changes on an existing user
return $meta;
}

if ( ! $locale ) {
Expand All @@ -33,6 +33,8 @@ function ( $user_id, $old_user_data, $user_data ) {
array( 'locale' => $locale ),
'wpcom'
);

return $meta;
},
8,
3
Expand Down

0 comments on commit 5120209

Please sign in to comment.