3

After logging in, the user name is not displaying between 'Wilkommen' and 'Anmelden' .

  1. Which files are responsible for rendering out this part of the header ?

  2. How to get the user name of the currently logged in user ?

enter image description here

Krishna ijjada
  • 8,927
  • 6
  • 41
  • 70
Blackpanther0001
  • 1,093
  • 5
  • 23
  • 37

2 Answers2

4

For customer name you need to check vendor/magento/module-theme/view/frontend/templates/html/header.phtml

code : <span data-bind="text: new String('<?php echo $block->escapeHtml(__('Welcome, %1!', '%1'));?>').replace('%1', customer().firstname)"> </span>

Data is being fetched by knockout js using :

<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "customer": {
                        "component": "Magento_Customer/js/view/customer"
                    }
                }
            }
        }
    }
    </script>
Ronak Chauhan
  • 6,183
  • 2
  • 28
  • 65
2

Which files are responsible for rendreing out this part of the header ?

/vendor/magento/module-theme/view/frontend/templates/html/header.phtml

<span data-bind="text: customer().fullname ? $t('Welcome, %1!').replace('%1', customer().fullname) : '<?=$block->escapeHtml($welcomeMessage) ?>'"></span>

If you have third party theme, the file path can be app/design/frontend/Vendorname/theme762/Magento_Theme/templates/html/header.phtml

How to get the username of the currently logged in user ?

Refer the answer

Krishna ijjada
  • 8,927
  • 6
  • 41
  • 70