Magento 2 - get user email IDMagento 2 Get customer ID from session in a block classget email id in email templateChange email logo for multistoreHow to get customer/guest user email address without using session in magentoMagento login not working properly with FPCGet customer email without sessionsGroup name from logged in userMagento 1.9 How to get Guest user id in CMS pages?Not able to sent the confirmation mail to the user?get Receiver's email-id in email header.html file magento2Magento 2: Login user programmatically showing wrong default header message “Default welcome msg!” instead of showing “Welcome, user!”
Giant Steps - Coltrane and Slonimsky
Why doesn't Adrian Toomes give up Spider-Man's identity?
Longest bridge/tunnel that can be cycled over/through?
Should I give professor gift at the beginning of my PhD?
How to use memset in c++?
How is John Wick 3 a 15 certificate?
Is this use of the expression "long past" correct?
Using "subway" as name for London Underground?
Geopandas and QGIS Calulating Different Polygon Area Values?
Did Milano or Benatar approve or comment on their namesake MCU ships?
Extreme flexible working hours: how to control people and activities?
Jargon request: "Canonical Form" of a word
Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?
You have (3^2 + 2^3 + 2^2) Guesses Left. Figure out the Last one
Certain search in list
Cascading Switches. Will it affect performance?
How does an ordinary object become radioactive?
Union with anonymous struct with flexible array member
How can I make some of my chapters "come to life"?
1980s live-action movie where individually-coloured nations on clouds fight
Tabular make widths equal
Does a scale have more than seven chords?
Arriving at the same result with the opposite hypotheses
How did old MS-DOS games utilize various graphic cards?
Magento 2 - get user email ID
Magento 2 Get customer ID from session in a block classget email id in email templateChange email logo for multistoreHow to get customer/guest user email address without using session in magentoMagento login not working properly with FPCGet customer email without sessionsGroup name from logged in userMagento 1.9 How to get Guest user id in CMS pages?Not able to sent the confirmation mail to the user?get Receiver's email-id in email header.html file magento2Magento 2: Login user programmatically showing wrong default header message “Default welcome msg!” instead of showing “Welcome, user!”
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm using Magento 2.2.6
, How can I get the email ID of logged in user to show in header.
Thanks.
magento2 email customer-account magento2.2.6 customer-session
add a comment |
I'm using Magento 2.2.6
, How can I get the email ID of logged in user to show in header.
Thanks.
magento2 email customer-account magento2.2.6 customer-session
magento.stackexchange.com/questions/128830/… Please check link and if you replace getId() with getEmail(), you will get email of logged in customer.
– Ramkishan Suthar
Nov 7 '18 at 9:55
Is this for Email ID or User ID ?
– user54226
Nov 7 '18 at 10:02
You need to change getId() with getEmail() to get customer email. Here is one more example. blogtreat.com/get-logged-in-customer-data-in-magento-2
– Ramkishan Suthar
Nov 7 '18 at 10:10
@user54226 add below code
– Balwant Singh
Nov 21 '18 at 12:56
add a comment |
I'm using Magento 2.2.6
, How can I get the email ID of logged in user to show in header.
Thanks.
magento2 email customer-account magento2.2.6 customer-session
I'm using Magento 2.2.6
, How can I get the email ID of logged in user to show in header.
Thanks.
magento2 email customer-account magento2.2.6 customer-session
magento2 email customer-account magento2.2.6 customer-session
edited May 31 at 8:55
Kazim Noorani
1,1351824
1,1351824
asked Nov 7 '18 at 9:37
user54226user54226
416
416
magento.stackexchange.com/questions/128830/… Please check link and if you replace getId() with getEmail(), you will get email of logged in customer.
– Ramkishan Suthar
Nov 7 '18 at 9:55
Is this for Email ID or User ID ?
– user54226
Nov 7 '18 at 10:02
You need to change getId() with getEmail() to get customer email. Here is one more example. blogtreat.com/get-logged-in-customer-data-in-magento-2
– Ramkishan Suthar
Nov 7 '18 at 10:10
@user54226 add below code
– Balwant Singh
Nov 21 '18 at 12:56
add a comment |
magento.stackexchange.com/questions/128830/… Please check link and if you replace getId() with getEmail(), you will get email of logged in customer.
– Ramkishan Suthar
Nov 7 '18 at 9:55
Is this for Email ID or User ID ?
– user54226
Nov 7 '18 at 10:02
You need to change getId() with getEmail() to get customer email. Here is one more example. blogtreat.com/get-logged-in-customer-data-in-magento-2
– Ramkishan Suthar
Nov 7 '18 at 10:10
@user54226 add below code
– Balwant Singh
Nov 21 '18 at 12:56
magento.stackexchange.com/questions/128830/… Please check link and if you replace getId() with getEmail(), you will get email of logged in customer.
– Ramkishan Suthar
Nov 7 '18 at 9:55
magento.stackexchange.com/questions/128830/… Please check link and if you replace getId() with getEmail(), you will get email of logged in customer.
– Ramkishan Suthar
Nov 7 '18 at 9:55
Is this for Email ID or User ID ?
– user54226
Nov 7 '18 at 10:02
Is this for Email ID or User ID ?
– user54226
Nov 7 '18 at 10:02
You need to change getId() with getEmail() to get customer email. Here is one more example. blogtreat.com/get-logged-in-customer-data-in-magento-2
– Ramkishan Suthar
Nov 7 '18 at 10:10
You need to change getId() with getEmail() to get customer email. Here is one more example. blogtreat.com/get-logged-in-customer-data-in-magento-2
– Ramkishan Suthar
Nov 7 '18 at 10:10
@user54226 add below code
– Balwant Singh
Nov 21 '18 at 12:56
@user54226 add below code
– Balwant Singh
Nov 21 '18 at 12:56
add a comment |
2 Answers
2
active
oldest
votes
First, create an instance in header.phtml file as below and also if more than one store is available and one wants to get mail in only one of the stores.
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$storeID = $storeManager->getStore()->getStoreId();
$storeName = $storeManager->getStore()->getName();
?>
<?php
$customerSession = $om->get('MagentoCustomerModelSession');
if($customerSession->isLoggedIn())
echo $customerSession->getCustomer()->getEmail(); // get Email
?>
Thanks, and how can I place it below the customer name in customer-welcome element.
– user54226
Nov 22 '18 at 14:32
user54226 Answer edited.
– SHEESHRAM
May 31 at 8:12
add a comment |
You need to inject MagentoCustomerModelSession $customerSession, class to get customer ID from customer session. Try this code.
protected $_customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession,
...
)
...
$this->_customerSession = $customerSession;
...
public function getCustomer()
echo $this->_customerSession->getCustomer()->getId(); //Print current customer ID
$customerData = $this->_customerSession->getCustomer();
print_r($customerData->getData()); //Print current Customer Data
echo 'Customer Id: ' . $customerData->getId() . '<br/>';
echo 'Customer Name: ' . $customerData->getName() . '<br/>';
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
echo 'Customer Group Id: ' . $customerData->getGroupId() . '<br/>';
NOTE: You only get customer id if customer logged in and customer session initialized
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f249277%2fmagento-2-get-user-email-id%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
First, create an instance in header.phtml file as below and also if more than one store is available and one wants to get mail in only one of the stores.
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$storeID = $storeManager->getStore()->getStoreId();
$storeName = $storeManager->getStore()->getName();
?>
<?php
$customerSession = $om->get('MagentoCustomerModelSession');
if($customerSession->isLoggedIn())
echo $customerSession->getCustomer()->getEmail(); // get Email
?>
Thanks, and how can I place it below the customer name in customer-welcome element.
– user54226
Nov 22 '18 at 14:32
user54226 Answer edited.
– SHEESHRAM
May 31 at 8:12
add a comment |
First, create an instance in header.phtml file as below and also if more than one store is available and one wants to get mail in only one of the stores.
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$storeID = $storeManager->getStore()->getStoreId();
$storeName = $storeManager->getStore()->getName();
?>
<?php
$customerSession = $om->get('MagentoCustomerModelSession');
if($customerSession->isLoggedIn())
echo $customerSession->getCustomer()->getEmail(); // get Email
?>
Thanks, and how can I place it below the customer name in customer-welcome element.
– user54226
Nov 22 '18 at 14:32
user54226 Answer edited.
– SHEESHRAM
May 31 at 8:12
add a comment |
First, create an instance in header.phtml file as below and also if more than one store is available and one wants to get mail in only one of the stores.
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$storeID = $storeManager->getStore()->getStoreId();
$storeName = $storeManager->getStore()->getName();
?>
<?php
$customerSession = $om->get('MagentoCustomerModelSession');
if($customerSession->isLoggedIn())
echo $customerSession->getCustomer()->getEmail(); // get Email
?>
First, create an instance in header.phtml file as below and also if more than one store is available and one wants to get mail in only one of the stores.
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$storeID = $storeManager->getStore()->getStoreId();
$storeName = $storeManager->getStore()->getName();
?>
<?php
$customerSession = $om->get('MagentoCustomerModelSession');
if($customerSession->isLoggedIn())
echo $customerSession->getCustomer()->getEmail(); // get Email
?>
edited May 31 at 8:11
answered Nov 21 '18 at 12:56
SHEESHRAMSHEESHRAM
586
586
Thanks, and how can I place it below the customer name in customer-welcome element.
– user54226
Nov 22 '18 at 14:32
user54226 Answer edited.
– SHEESHRAM
May 31 at 8:12
add a comment |
Thanks, and how can I place it below the customer name in customer-welcome element.
– user54226
Nov 22 '18 at 14:32
user54226 Answer edited.
– SHEESHRAM
May 31 at 8:12
Thanks, and how can I place it below the customer name in customer-welcome element.
– user54226
Nov 22 '18 at 14:32
Thanks, and how can I place it below the customer name in customer-welcome element.
– user54226
Nov 22 '18 at 14:32
user54226 Answer edited.
– SHEESHRAM
May 31 at 8:12
user54226 Answer edited.
– SHEESHRAM
May 31 at 8:12
add a comment |
You need to inject MagentoCustomerModelSession $customerSession, class to get customer ID from customer session. Try this code.
protected $_customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession,
...
)
...
$this->_customerSession = $customerSession;
...
public function getCustomer()
echo $this->_customerSession->getCustomer()->getId(); //Print current customer ID
$customerData = $this->_customerSession->getCustomer();
print_r($customerData->getData()); //Print current Customer Data
echo 'Customer Id: ' . $customerData->getId() . '<br/>';
echo 'Customer Name: ' . $customerData->getName() . '<br/>';
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
echo 'Customer Group Id: ' . $customerData->getGroupId() . '<br/>';
NOTE: You only get customer id if customer logged in and customer session initialized
add a comment |
You need to inject MagentoCustomerModelSession $customerSession, class to get customer ID from customer session. Try this code.
protected $_customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession,
...
)
...
$this->_customerSession = $customerSession;
...
public function getCustomer()
echo $this->_customerSession->getCustomer()->getId(); //Print current customer ID
$customerData = $this->_customerSession->getCustomer();
print_r($customerData->getData()); //Print current Customer Data
echo 'Customer Id: ' . $customerData->getId() . '<br/>';
echo 'Customer Name: ' . $customerData->getName() . '<br/>';
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
echo 'Customer Group Id: ' . $customerData->getGroupId() . '<br/>';
NOTE: You only get customer id if customer logged in and customer session initialized
add a comment |
You need to inject MagentoCustomerModelSession $customerSession, class to get customer ID from customer session. Try this code.
protected $_customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession,
...
)
...
$this->_customerSession = $customerSession;
...
public function getCustomer()
echo $this->_customerSession->getCustomer()->getId(); //Print current customer ID
$customerData = $this->_customerSession->getCustomer();
print_r($customerData->getData()); //Print current Customer Data
echo 'Customer Id: ' . $customerData->getId() . '<br/>';
echo 'Customer Name: ' . $customerData->getName() . '<br/>';
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
echo 'Customer Group Id: ' . $customerData->getGroupId() . '<br/>';
NOTE: You only get customer id if customer logged in and customer session initialized
You need to inject MagentoCustomerModelSession $customerSession, class to get customer ID from customer session. Try this code.
protected $_customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession,
...
)
...
$this->_customerSession = $customerSession;
...
public function getCustomer()
echo $this->_customerSession->getCustomer()->getId(); //Print current customer ID
$customerData = $this->_customerSession->getCustomer();
print_r($customerData->getData()); //Print current Customer Data
echo 'Customer Id: ' . $customerData->getId() . '<br/>';
echo 'Customer Name: ' . $customerData->getName() . '<br/>';
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
echo 'Customer Group Id: ' . $customerData->getGroupId() . '<br/>';
NOTE: You only get customer id if customer logged in and customer session initialized
answered Nov 21 '18 at 12:53
Balwant SinghBalwant Singh
3991316
3991316
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f249277%2fmagento-2-get-user-email-id%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
magento.stackexchange.com/questions/128830/… Please check link and if you replace getId() with getEmail(), you will get email of logged in customer.
– Ramkishan Suthar
Nov 7 '18 at 9:55
Is this for Email ID or User ID ?
– user54226
Nov 7 '18 at 10:02
You need to change getId() with getEmail() to get customer email. Here is one more example. blogtreat.com/get-logged-in-customer-data-in-magento-2
– Ramkishan Suthar
Nov 7 '18 at 10:10
@user54226 add below code
– Balwant Singh
Nov 21 '18 at 12:56