Redirect to profile after login

Hi all,

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

Thanks

Conrad

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.
 
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:

Rich (BB code):
		return $this->responseRedirect(
			XenForo_ControllerResponse_Redirect::SUCCESS,
			//$redirect
			XenForo_Link::buildPublicLink('members', XenForo_Visitor::getInstance()->toArray())
		);
 
return $this->responseRedirect( XenForo_ControllerResponse_Redirect::SUCCESS, //$redirect XenForo_Link::buildPublicLink('members', XenForo_Visitor::getInstance()->toArray()) );

This didn't seem to work, is there any changes since this was posted?
 
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
 
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())
);
}
 
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..
 
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..
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.
 
Back
Top Bottom