How to correctly override the "Sign in" text in the header top links in Magento 2.3

Hi, I’ve been trying now for a couple of hours and still struggle to find a way to modify the text “Sign in” into “[icon] Login” in the top links section in the header.

I saw some solutions that require to create a custom module and then through the “di.xml” file and the overridden class to modify the getLabel method. But nothing seems to happen.

So, how do I change the text and also add an icon?

The answer to your question will vary based on your theme. I can’t give you an exact answer right now, but I can give you a potential lead…

  1. You’ll need to override a core Magento file inside a custom module (I don’t think you can override this particular file inside a Child Theme)
  2. I think the file you need to override is listed below:

vendor/magento/module-customer/Block/Account/AuthorizationLink.php

I’m not 100% sure on that, but see how you get on.

Thanks for your answer.

I’m working on a clan template (no parent template) and I’ve been trying to override the getLabel() function present in the Block you have indicated. Unfortunately I can’t see any difference in the outcome.

Have you any idea on what would be the best approach? Should I use the Preference tag in the di.xml file in my custom module or should I make a Plugin to alter the result of the getLabel function?

I’m not sure. It’s been a while since I’ve had to override something like this. I’m shooting off for the weekend. But if I get an opportunity I’ll sit down and have a play around. But this might be my starting point. I’d just need to work out which xml to add in order to include the phtml as an override.

Maybe
Let me know how you get on if you pursue this over the weekend. Good luck

So after some online digging I found out that the “best” option was to create a plugin that and use the “after” method to change the value to output.

But as I wanted to go from Login (when not logged in) to Account (when logged in) I thought the best thing to do would be to create my custom **block ** inspired by the AuthorizationLink block. And so I made a custom block that shows:

[icon] Login (when not logged)
and
[icon] Account (when logged in)

Thanks again for your suggestions!

Can you breakdown what you did to create your module? I’m sure others will find this useful.