We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Redirecting gusts to a specific page | Forum

Mehroz
Mehroz Mar 16 '15
Hello,


when a user visits my site how can i redirect it to a specific page or link if its not logged in ?

Mehroz
Mehroz Mar 17 '15
no i dont want to use a paid plugin for that i want to learn oxwall for development....


Nickolay
Nickolay Mar 17 '15
Use Oxwall Events, like OW_EventManager::ON_APPLICATION_INIT or OW_EventManager::ON_AFTER_ROUTE. Example: OW::getEventManager()->bind(OW_EventManager::ON_APPLICATION_INIT , 'redirectHandlerFunction');



Mehroz
Mehroz Mar 17 '15
i will give it a try
Marina Bircher
Marina Bircher Apr 15 '15

Quote from NickolayExample: OW::getEventManager()->bind(OW_EventManager::ON_APPLICATION_INIT , 'redirectHandlerFunction');



And then? Where can we define the url? and trigger it?


thx


Oxwall Tips
Oxwall Tips Apr 16 '15
Marina, where would you like to redirect user to? Is that one of the inner local pages or completely external links that don't belong to Oxwall's script?
Mehroz
Mehroz Apr 16 '15
the thing i got from this thread is you would to make a plugin and use this example in that  you would need 2 urls, 1 which is the original url and 2 on which you want to redirect ( based on decision if the user is currently logged in or not)... you can get further help from this link: http://www.ewtnet.com/...e-for-logged-in.html

hover ever what i was trying to do was this:
http://www.ewtnet.com/...sign-in-page-as.html
and above mentioned link which i used full filled my need
Mehroz
Mehroz Apr 16 '15
without proper documentation making oxwall plugin is really difficult oxwall should improve its documentation to make itself more popular and developer friendly
The Forum post is edited by Mehroz Apr 16 '15
Nickolay
Nickolay Apr 17 '15

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 */);

               }

}