Magento 2 override the cutomer account loginpost controller
You need to rewrite the customer loginPost plugin file as per the below
<?php
namespace VENDOR\MYMODULENAME\Plugin\Customer;
class LoginPost
{
public function __construct(
\Magento\Framework\App\Action\Context $context
) {
$this->_request = $context->getRequest();
$this->_response = $context->getResponse();
$this->resultRedirectFactory = $context->getResultRedirectFactory();
$this->resultFactory = $context->getResultFactory();
}
public function aroundExecute(\Magento\Customer\Controller\Account\LoginPost $subject, $proceed)
{
$login = $this->_request->getPost('login');
$custom_redirect= false;
$returnValue = $proceed();
if (isset($login['press_room_page'])) {
$custom_redirect=true;
}
if (isset($login['press_room_page']) && $custom_redirect) {
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('mycustomlogin/index');
return $resultRedirect;
}
return $returnValue;
}
}