Skip to content
  • LinkedIn
  • Twitter
  • Facebook

Desssigner.in

Aryan Srivastava | Adobe Commerce Certified Developer | Magento Tutor

  • Home
  • About Me
  • Contact
  • Toggle search form
How to Add Logout Tab to Customer Account

How to Add Logout Tab to Customer Account in Magento 2?

Posted on August 9, 2021August 26, 2021 By Aryan Srivastava No Comments on How to Add Logout Tab to Customer Account in Magento 2?

In this article, I am going to explain how to add Logout Tab to customer account. Most of the users search for the Logout / Sign Out link in the customer account dashboard. We can add Logout / Sign Out to the customer account.

You may also be interested in:

  1. How to Display Products by Custom Attribute in Magento 2?

Let’s start

You need to add customer_account.xml file under /app/design/frontend/<Vendor>/<theme>/Magento_Customer/layout/

In my case it is :

/app/design/frontend/Aryan/Tutorial/Magento_Customer/layout/

Aryan => Vendor

Tutorial => Theme

Content for customer_account.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="customer_account_navigation">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="customer.account.logout">
<arguments>
<argument name="label" xsi:type="string" translate="true">Logout</argument>
<argument name="path" xsi:type="string">customer/account/logout</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>

Once done with file addition in your theme, do cache flush:

$ php bin/magento c:f

Output :

Customer Account Logout
Logout Link

How to Add Custom Link to Customer Dashboard?

If you want to add a custom link/tab to the customer dashboard, you can easily do it. Let’s see how to add a custom link.

For example, I want to add the Customer Demo tab which will redirect to the URL customer-demo.

Edit customer_account.xml in your theme.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="customer_account_navigation">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="customer.demo" before="customer.account.logout">
<arguments>
<argument name="label" xsi:type="string" translate="true">Customer Demo</argument>
<argument name="path" xsi:type="string">customer-demo</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>

Clear Cache

$ php bin/magento c:f

Output:

Custom tab to customer dashboard
Custom tab to customer dashboard

How to remove Tab from Customer Account?

Removing the existing tab from the customer account dashboard is very simple. We just need to remove that block in our customer_account.xml

<referenceBlock name="name of the block" remove="true" />

For example, let remove the Customer Demo tab which we added above.

<referenceBlock name="customer.demo" remove="true" />

Now, Clear the cache to see the change.


Hope this article helped you to understand how to add links to the customer account dashboard. If you have any queries, you can ask me directly over email at aryansrivastavadesssigner@gmail.com or contact me here.

If you want a live session, do direct ping me on LinkedIn I will arrange an online session on weekends.

If you like this article, you can buy me a cup of coffee Buy me a Coffee.

Post Views: 1,020
How To?, Magento, Magento2 Tags:Customer Dashboard, Logout link, Magento, Magento2

Post navigation

Previous Post: How to Display Products by Custom Attribute in Magento 2?
Next Post: Magento2 Useful Command List

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Command list Customer Dashboard Custom Module File override Frontend How to Layout Logout link Magento Magento2 Magento2 Cheat Sheet Magento Tutorial Product Page Theme Tutorial View.xml

CERTIFICATION DIRECTORY

Adobe Commerce Front-End Developer

Adobe Certified Professional - Adobe Commerce Front-End Developer

Adobe Certified Expert-Adobe Commerce Front-End Developer

Copyright © 2023 Desssigner.in.

Powered by PressBook WordPress theme

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT