0

In my case, i have two type of customer: for local customer i will keep the firstname lastname in top link if it's connected else i want to display a custom attribute that i added in registration form so i will have instead this information and then the dropdown in top link so how to proceed please any help ? enter image description here

3

2 Answers 2

1

Please try below code

<? 
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $customerRepositoryInterface = $objectManager->create('\Magento\Customer\Api\CustomerRepositoryInterface');
    $customerSession = $objectManager->create('Magento\Customer\Model\Session');
    if($customerSession->isLoggedIn()) {
        $customerId = $customerSession->getCustomer()->getId();
        $customeratt = $customerRepositoryInterface->getById($customerId);
        $customAttributeCode = 'custom_name';
        echo $cattrValue = $customeratt->getCustomAttribute($customAttributeCode); //Please echo this line when you want display custom name.
    }
?>
3
  • thanks for your replay just one question where to put this code Jan 23, 2019 at 8:37
  • Override this file into your theme and put in respective <li> tag vendor/magento/module-customer/view/frontend/templates/account/customer.phtml Jan 23, 2019 at 10:13
  • i tried this and i get a white page with just icon of language and the label skip menu Jan 28, 2019 at 16:38
0

Turn on debug hint mode in BO and override in theme

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.