Linked Questions

8
votes
7answers
14k views

How can i check whether user is logged in or not in magento 2.0 [duplicate]

How can I check whether user is logged in or not in Magento 2.0 I using phtml file I want to check user logged in or not. <span class="selllink switcher top-links"> <span class="" data-...
5
votes
2answers
8k views

How to check if customer is logged in and get customer Id in magento 2 [duplicate]

How can i check if the customer has logged in to the magento and get the customer details like id, first name, last name, etc., I have tried this in 2 ways 1). Using the session in a block as below ...
3
votes
2answers
1k views

Magento 2: The direct use of ObjectManager is discouraged [duplicate]

when I am check using object manager it gives me warning that The direct use of ObjectManager is discouraged. Inject necessary dependencies via constructor". How to solve this problem and I also want ...
1
vote
2answers
692 views

Checking if customer is logged in only working on account pages [duplicate]

So, I followed the steps in the 2nd answer (by Miroslav Petroff) on this question: How can i check whether user is logged in or not in magento 2.0 The if statement only works correctly when viewing ...
0
votes
2answers
304 views

Changing link being cached [duplicate]

I have modified a themes account_links.phtml file. Client has requested that it just says "Login" and if logged in it should just show "My Account". This is the code I came up with: $objectManager =...
0
votes
2answers
266 views

To check the user in logged in or not in Magento 2 [duplicate]

I have used the following code to check the user is logged or not. It always show me "Login Failed" after the user is logged to the site also. $objectManager = \Magento\Framework\App\ObjectManager::...
3
votes
3answers
50 views

Magento 2 - Check if user is loggen in header.html [duplicate]

I'm trying to create a piece of code to check if the customer is loggen in or not. I read not to use the objectmanager for that, but I don't know where to put which code. What I need: if customer is ...
0
votes
0answers
59 views

Check user logged in or not? [duplicate]

I want to check that user is logged in or not in order to hide add to cart button for guest users. I have created a module in which I have override addtocart.phtml file and added the below code: <?...
126
votes
7answers
83k views

Magento 2: to use or not to use the ObjectManager directly?

Ok, so yesterday we had a big talk with other people from the Magento community regarding the direct use of the ObjectManager in classes/templates. I'm already aware of the reasons why we shouldn't ...
13
votes
5answers
11k views

How to get current customer group id in magento2

I want to get current customer group id in phtml file. When I am not logged in still it is return general type customer group. How can get proper output?
6
votes
1answer
5k views

magento2 check if customer is logged in or not in knockout template

How do I check if customer is logged in or not in knockout template? my template <!-- ko if: customer().firstname --> <!-- /ko --> my js define( [ 'ko', 'jquery', ...
3
votes
2answers
1k views

After logging in, the user name is not displaying in header section

After logging in, the user name is not displaying between 'Wilkommen' and 'Anmelden' . Which files are responsible for rendering out this part of the header ? How to get the user name of the ...
1
vote
4answers
2k views

Magento 2 check if customer is logged in in admin area

I have the following code to see if a user is logged in. It sort of works as in it works within the customer area (user logged in) but doesn't work outside of the customer area even though the ...
2
votes
3answers
2k views

How to get current customer id in helper class of module in magento2

I want to get current customer id in Helper class of module in magento2. How to get using helper in Magento 2. Can anyone help me?
2
votes
2answers
2k views

How to Hide Header(Primary) Menu before login (for Visitors)?

Magento 2 Version - Magento 2.1.4 CE I am trying to create Custom Module for Compulsory login. When user hits the website url it must needs to redirect on login screen and after logged in user can ...

15 30 50 per page