3

This question already has an answer here:

How can I remove certain elements in the layout, but only when the customer is not logged in? In Magento 1, there was a logged in handle, but is there an equivalent in Magento 2?

marked as duplicate by Rajeev K Tomy, Jai, Manoj Deswal, Piyush, liyakat Apr 3 '18 at 11:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

I think you are looking for the alternatives of customer_logged_in and customer_logged_out layout handles which are available in M1. Unfortunately the answer is NO. We don't have such layout handles available in M2.

But you have two events for this. They are customer_login and customer_logout. You need to use these events to achieve the desired result.

If you need this behavior via layout updates, then the only option which comes to my mind is the conditional blocks. However this only allows system configuration settings and hence cannot rely on this.

So in short, the desired behavior is not possible via layout updates and hence you need to look for other work around such as this

Edit

More details are in this link

1

There are two different handle for magento 2 also,

customer_account_index.xml Used when the customer is Login,

customer_account_login.xml used when the customer is guest(not login)

  • Yes, but is there also a (for example), default.xml type layout file, specifically for logged in / not logged in users? – Maarten Wolfsen Apr 3 '18 at 9:42
  • This is not right answer – Sourav Apr 3 '18 at 10:24

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