when a user visits my site how can i redirect it to a specific page or link if its not logged in ?
when a user visits my site how can i redirect it to a specific page or link if its not logged in ?
Example: OW::getEventManager()->bind(OW_EventManager::ON_APPLICATION_INIT , 'redirectHandlerFunction');And then? Where can we define the url? and trigger it?
thx
> And then? Where can we define the url? and trigger it?
'redirectHandlerFunction' in example above is of type callable (you can do it a method in your class or else), so this is how it'll work with redirect here:
function redirectHandlerFunction()
{
//
example check for post request in specific controller/action
$request
= OW::getRequestHandler()->getHandlerAttributes();
if(OW::getRequest()->isPost()
&& $request['controller'] == 'SOME_Controller' &&
$request['action'] == 'someAction') {
OW::getApplication()->redirect(/*
some url */);
}
}