Magento 2.2.5 Header – How to Change Create Account Link

headermagento-2.2.5magento2xml

I want to change the URL of the "create An account" link that is on the top right of the site. I want the link to instead of being customer/account/create/ I want it to be customer/account/login

I believe I have to edit the default xml file that is

app/design/frontend/Smartwave/porto_child/Magento_Customer/layout

here is the file just not sure how to edit it

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="header.links">
        <block class="Magento\Customer\Block\Account\Customer" name="customer" template="account/customer.phtml" before="-"/>
        <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link-login" template="account/link/authorization.phtml"/>
    </referenceBlock>
    <block class="Magento\Theme\Block\Html\Header" name="header" as="header">
        <arguments>
            <argument name="show_part" xsi:type="string">welcome</argument>
        </arguments>
    </block>
    <move element="header" destination="header.links" before="-"/>
    <move element="register-link" destination="header.links"/>
    <move element="top.links" destination="customer"/>
    <move element="authorization-link" destination="top.links" after="-"/>
  </body>
</page>

Best Answer

Change class of block register-link to Magento\Framework\View\Element\Html\Link

Now you can pass the parameter path to change link

So your final default.xml should look like this:

app/design/frontend/Smartwave/porto_child/Magento_Customer/layout/default.xml

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="top.links">
        <block class="Magento\Framework\View\Element\Html\Link" name="register-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
                <argument name="path" xsi:type="string" translate="true">customer/account/login</argument>
            </arguments>
        </block>
    </referenceBlock>

    ....
    ....
  </body>
</page>
Related Topic