Skip to content

Create popup after customer logged in

How to show a popup as soon as customer logs in. I created an customer_login event and called an observer, I want to display a phtml file with my popup code. Following doesn’t work

etc/frontend/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="VendorModuleObserverCustomerLogin" />
    </event>
</config>

Observer/CustomerLogin.php

<?php

declare(strict_types = 1);

namespace VendorModuleObserver;

use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
//use MagentoFrameworkViewResultPageFactory;


class CustomerLogin implements ObserverInterface
{
    
    public function execute(Observer $observer)
    {
        
        //code to call phtml file that modal popup
    }
}