I write an observer to observe the customer_register_success
event and run the following codes to do the redirect but failed. Can anyone help?
$url = $this->url->getUrl('/');
$observer->getControllerAction()->getResponse()->setRedirect($url);
$this->logger->debug("Redirect to: {$url}");
Best Answer
I think the problem is that your redirect is occuring before the default redirect and hence has no effect. Here's a module that does the job:
Module directory structure:
di.xml :
events.xml:
Register.php:
Redirect.php:
It works by setting a flag in the core registry when the
customer_register_success
event occurs and then checks for that flag and returns an alternate redirect path when the redirect for a successful customer authentication is requested instead of the default 'My Account' page. Hope this helps.