Magento 2: Get Customer data after login with observer
Use customer_login event observer for customer login action
1) Create events.xml
app/code/Vendor/Module/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="customer_login">
<observer name="customer_login_observer" instance="Vendor\Module\Observer\CustomerLogin" />
</event>
</config>
2) Now create observer CustomerLogin.php
app/code/Vendor/Module/Observer/CustomerLogin.php
<?php
namespace Vendor\Module\Observer;
use Magento\Framework\Event\ObserverInterface;
class CustomerLogin implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
echo "Customer LoggedIn";
$customer = $observer->getEvent()->getCustomer();
echo $customer->getName(); //Get customer name
exit;
}
}