Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Last active August 13, 2017 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cgi-caesar/9e8e7b8d2afacd5bdbf72cc558eb4fd6 to your computer and use it in GitHub Desktop.
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
<?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