I’m getting the name of my user that I load from the profile. It’s works fine on my local, but on my prod, the firstname displayed is showing the name from the previous user. How do I prevent that ? This is how I get my data.
This is where I don’t understand, I’m loading data by current user, but the user isn’t the good one…
I have my "new" firstname only after clearing my website cache with drush
/** * Implements hook_preprocess_HOOK(). */ function frr_menu_link_preprocess_menu__account(&$variables) { $current_user = Drupal::currentUser(); $variables['firstname'] = FALSE; if($current_user->isAuthenticated()) { $entity_manager = Drupal::entityTypeManager(); $profileStorage = $entity_manager->getStorage('profile'); $profileCustomerFound = $profileStorage->loadByProperties([ 'uid' => $current_user->id(), 'type' => 'customer', 'is_default' => 1, 'status' => 1, ]); if($profileCustomerFound > 0) { $customer = end($profileCustomerFound); $firstname = $customer->get('field_firstname')->value; $variables['firstname'] = !empty($firstname) ? ucfirst($firstname) : FALSE; } } }