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

[Answered] How can to redirect to a page after login | Forum

Kali
Kali May 4 '15
Hello,

I would like to redirect to a specific page after login, where can I modify the code?

Thanks,
Kali
The Forum post is edited by Alia May 15 '15
Kali
Kali May 5 '15
So far I found the event ON_USER_LOGIN so I'm trying something like that:

public function onUserLogin( OW_Event $e )
    {
      $url = OW::getRouter()->urlForRoute('base_member_dashboard');
        OW::getApplication()->redirect($url);
    }

and in my init:

$em->bind(OW_EventManager::ON_USER_LOGIN, array($this, 'onUserLogin'));

But it doesn't work... Any pointer would be greatly appreciated :)
PRINCEWILL DICKSON
PRINCEWILL DICKSON May 5 '15
get the redirect plugin and choose the url you want  its as simple as ABC.I got the plugin,installed it and i am done with that.


Hope this helps

Kali
Kali May 5 '15
Well I want to learn how to do it myself in oxwall, but thanks anyway ;)
Alia Team
Alia May 15 '15
Kali, routing processes after sign in are described in   ow_system_plugins/base/controllers/user.php  file.

There are two ways people can sign in to your site:

1. Standard sign in ( using www.sitename.com/sign-in URL): standardSignIn

public function standardSignIn()
    { .......
        $this->redirect(OW::getRouter()->getBaseUrl() . urldecode($_GET['back-uri']));
     }

Instead of Base URL you can specify another route.

2. Ajax sign in ( when signin in from console): ajaxSignIn

public function ajaxSignIn()
    { ........
 if ( $result->isValid() )
            {
                exit(json_encode(array('result' => true, 'message' => $message)));
            }

With ajax sign in you will need to add your own sign in  logic code instead of $message.



Where would you like to redirect users?
I personally find it very frustrating when I get redirected anywhere after signing in in cases when I, for example,  open link to certain user profile and after signing in I get redirected to completely another page instead of staying on the page which I opened ( but with loged in status).

Any modifications done to this file might be erased if you update core platform in future.



Kali
Kali Jun 8 '15
I would like to do it only for the homepage to redirect users to their timeline, many of my users are complaining about that. Thank you for your answer, I'll have a look into it.

For future updates it would be awesome if it was possible to override files from the core, instead of touching them directly :)