As per as, our discussion, I am sharing an idea that might help you.
- First, pass a registry variable from initiatePasswordReset that
registry variable will contain your desired URL.
- Then at
controller_action_postdispatch_customer_account_forgotPasswordPost
event
catch that registry variable value, that page
Create Plugin over initiatePasswordReset
call and use after, before ,around method depend on your choose.
Here, i am using around method.
<?php
/**
* Created by Amit Bera.
* User: Amit Kumar Bera
* Email: [email protected]
* Date: 19-05-2018
* Time: 17:03
*/
namespace StackExchange\Works\Plugin;
use Magento\Framework\Registry;
class InitiatePasswordResetPlugin
{
protected $registry;
public function __construct(
Registry $registry
)
{
$this->registry = $registry;
}
public function aroundInitiatePasswordReset(
\Magento\Checkout\Model\Session $subject,
\Closure $proceed,
$email,
$template,
$websiteId
)
{
// Do business logic here
if($this->registry->registry('my_custom_redirect')){
$this->registry->unregister('my_custom_redirect');
}
$this->registry->register('my_custom_redirect','{YourUrl}');
return $proceed($email, $template, $websiteId);
}
}
Now, controller_action_postdispatch_customer_account_forgotPasswordPost
event,
redirect that URL my_custom_redirect
.
<?php
namespace StackExchange\Works\Observer\Frontend;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Registry;
class ControllerActionPostdispatchForgotPasswordPost implements ObserverInterface
{
/**
* @var \Magento\Framework\App\ActionFlag
*/
protected $actionFlag;
public function __construct(
\Magento\Framework\App\ActionFlag $actionFlag,
Registry $registry
) {
$this->registry = $registry;
$this->actionFlag = $actionFlag;
}
public function execute(Observer $observer)
{
$action = $observer->getEvent()->getControllerAction();
if($this->registry->registry('my_custom_redirect')){
$this->actionFlag->set('', \Magento\Framework\App\ActionInterface::FLAG_NO_DISPATCH, true);
$action->getResponse()->setRedirect($this->registry->registry('my_custom_redirect'));
return $this;
}
return $this;
}
}