Skip to content

Instantly share code, notes, and snippets.

@jrxpress jrxpress/site.php forked from cgi-caesar/site.php
Created Aug 13, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.