In default magento functionality : customer register after redirect to
my account page but I want to redirect previous page
My code :
<?php
namespace Vendor\Registerredirect\Plugin;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Registry;
use Magento\Framework\UrlInterface;
use Magento\Framework\App\Response\RedirectInterface;
class Redirect
{
protected $coreRegistry;
protected $url;
protected $resultFactory;
public function __construct(Registry $registry, UrlInterface $url, ResultFactory $resultFactory, RedirectInterface $redirect)
{
$this->coreRegistry = $registry;
$this->url = $url;
$this->resultFactory = $resultFactory;
$this->redirect = $redirect;
}
public function aroundGetRedirect ($subject, \Closure $proceed)
{
if ($this->coreRegistry->registry('is_new_account')) {
/** @var \Magento\Framework\Controller\Result\Redirect $result */
$result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$result->setUrl($this->redirect->getRefererUrl());
return $result;
}
return $proceed();
}
}
any one know how to solve above code or other code if it is working ..
Any idea how can achieve that ?
Thanks in advance