0

I have an observer that is triggered when a user creates an account. In the execute method I have the following code:

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $redirectionUrl = $this->url->getUrl('subscribe');
    $this->responseFactory->create()->setRedirect($redirectionUrl)->sendResponse();
    exit;
}

It does infact redirect as expected, but the user is not logged in after registration.

How can I redirect without having to use exit? If I remove exit the redirect doesn't happen.

4
  • Instead of exit just use return $this. May 12 at 4:31
  • Doing so causes the redirect to fail, and instead the user is redirected to their account page. This is not what I want. May 12 at 5:01
  • What is the event you are attaching this observer to?
    – Joao71
    May 12 at 10:29
  • customer_register_success May 13 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.