0

I have a popup for login in custom page when user login from custom page i want to trigger an event "log in"

& in that event i am trying to pass the "location" property.

I am not sure how can i append this location to the event so that in my observer i can fetch it as

$observer->getEvent()->getData('location');

Any thoughts on this ? Thankyou

1 Answer 1

1
protected $_eventManager;

public function __construct(
    \Magento\Framework\Event\ManagerInterface $eventManager,
) {
    $this->_eventManager = $eventManager;
}

public function execute()
{
    //you can pass param value and set condition here as per your requirement. 
    $this->_eventManager->dispatch(
                'customer_login_observer',
                ['location' => $location, 'request' => $this->getRequest()]
            );
}
2
  • Thanks for the answer kushal, can i extend the event for exg i am trying for "customer_login" event, can i extend the dispatch of this event in my custom file ?
    – php dev
    Commented Feb 3, 2021 at 10:49
  • No you can't extend an event but you can create multiple observers for that event in different modules. Though the order of execution is not guaranteed. Commented Feb 3, 2021 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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