1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect to profile after login

Discussion in 'XenForo Development Discussions' started by Conrad, Mar 24, 2013.

  1. Conrad

    Conrad Member

    Hi all,

    Is it possible to redirect to the members profile after login?

    Thanks

    Conrad
     
    DRE likes this.
  2. account8226

    account8226 Guest

    I think you need an add-on for this. It's quite easy to do, but I don't think you're able to do this with template edits.
     
  3. Brogan

    Brogan XenForo Moderator Staff Member

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The problem is that you don't know which profile page you are redirecting to until the user logs in. Therefore you need to edit the code:

    library/XenForo/ControllerPublic/Login.php

    At the bottom of actionLogin(), add the red code:

    Code:
    		return $this->responseRedirect(
    			XenForo_ControllerResponse_Redirect::SUCCESS,
    			//$redirect
    			XenForo_Link::buildPublicLink('members', XenForo_Visitor::getInstance()->toArray())
    		);
    
     
    rafass, Glockie, DRE and 2 others like this.
  5. Conrad

    Conrad Member

    Yep that works!

    Many Thanks
     
  6. DRE

    DRE Well-Known Member

    Great idea dude.
     
  7. gunnar

    gunnar Active Member

    Would it be possible to do this only on first login? When the account is created?
     
  8. gunnar

    gunnar Active Member

    This didn't seem to work, is there any changes since this was posted?
     
  9. Glockie

    Glockie Well-Known Member

    No, works perfectly fine here and running 1.5
    Have you added it into the correct part of the file
    :)
     
  10. gunnar

    gunnar Active Member

    Thanks, could it be because I'm using xenporta?
     
  11. Glockie

    Glockie Well-Known Member

    Pass I'm not familiar with Xenporta unfortunately..
    Sorry I can't help there.
     
  12. gunnar

    gunnar Active Member

    I was wondering if that would override the redirect settings, seems unlikely though..
     
  13. Glockie

    Glockie Well-Known Member

    Have you added it to the correct line?
    There's 9 redirects with the same or similar lines.

    In notepad++ it is roughly on lines 233 - 236
     
  14. gunnar

    gunnar Active Member

    I have added like this (marked colour to make it visible:

    public function actionLogin()
    {
    $data = $this->_input->filter(array(
    'login' => XenForo_Input::STRING,
    'password' => XenForo_Input::STRING,
    'remember' => XenForo_Input::UINT,
    'register' => XenForo_Input::UINT,
    'cookie_check' => XenForo_Input::UINT,
    'postData' => XenForo_Input::JSON_ARRAY
    ));

    if ($data['register'] || $data['password'] === '')
    {
    return $this->responseReroute('XenForo_ControllerPublic_Register', 'index');
    }

    $redirect = $this->getDynamicRedirectIfNot(XenForo_Link::buildPublicLink('login'));

    if (XenForo_Visitor::getUserId())
    {
    return $this->responseRedirect(
    XenForo_ControllerResponse_Redirect::SUCCESS,
    //$redirect
    XenForo_Link::buildPublicLink('members', XenForo_Visitor::getInstance()->toArray())
    );
    }
     
    Glockie likes this.
  15. gunnar

    gunnar Active Member

    It was the wrong place! line 233-236 worked! Thanks!

    I would still prefer it only to happen on first login.. or once a week/month..
     
    Glockie likes this.
  16. Glockie

    Glockie Well-Known Member

    You're most welcome..
    I don't think that would be possible, but someone with better knowledge may be able to help you there.
    Glad it helped :)
    Merry Christmas to you.
     
  17. gunnar

    gunnar Active Member

    Happy Christmas!!
     
    Glockie likes this.

Share This Page