Last active
August 13, 2017 07:28
-
-
Save cgi-caesar/9e8e7b8d2afacd5bdbf72cc558eb4fd6 to your computer and use it in GitHub Desktop.
aMember (site.php): How to redirect user to custom landing page once he cancel his subscription
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->front->registerPlugin(new class extends Zend_Controller_Plugin_Abstract { | |
public function preDispatch(Zend_Controller_Request_Abstract $request) | |
{ | |
if ($request->getModuleName() == 'default' && | |
$request->getControllerName() == 'member' && | |
$request->getActionName() == 'payment-history') { | |
$di = Am_DI::getInstance(); | |
if ($invoice = $di->invoiceTable->findFirstBy(array( | |
'tm_cancelled' => ">" . sqlTime("-5 minute") | |
))) { | |
if (!$invoice->data()->get('redirect_done')) { | |
$invoice->data()->set('redirect_done', 1); | |
$invoice->save(); | |
$request->setDispatched(true); | |
$this->getResponse()->setRedirect('/cancel.php'); | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment