• 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

A

account8226

Guest
#2
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.
 

Jake Bunce

XenForo moderator
Staff member
#4
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())
		);
 

Glockie

Well-known member
#13
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
 

gunnar

Active member
#14
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

Well-known member
#16
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.