1 (edited by luca 2013-09-07 16:33)

Topic: login redirect (solved)

I had installed Punbb as a part of a website, now i need that after login users will be redirected ti index of entire website, not index of direcotory forum where is installed punbb, where i can modify the redirect target after login in code?
thanks in adavnced
Luca

Re: login redirect (solved)

I am sure, you have already found it, but just in case I will explain this to you.

You have to make modifications in login.php, directly above the hook 'li_login_pre_redirect'. Your code should looks like that:

        $expire = ($save_pass) ? time() + 1209600 : time() + $forum_config['o_timeout_visit'];
        forum_setcookie($cookie_name, base64_encode($user_id.'|'.$form_password_hash.'|'.$expire.'|'.sha1($salt.$form_password_hash.forum_hash($expire, $salt))), $expire);

        $_POST['redirect_url'] = 'https://google.com/'; /* <-- THIS LINE I HAVE ADDED */
        ($hook = get_hook('li_login_pre_redirect')) ? eval($hook) : null;
        redirect(forum_htmlencode($_POST['redirect_url']).((substr_count($_POST['redirect_url'], '?') == 1) ? '&amp;' : '?').'login=1', $lang_login['Login redirect']);

If you want to redirect to the main page of your domain, you should use "/" as address. fe. $_POST['redirect_url'] = '/'; After redirecting the parameter "login=1" will be attached, but this doesn't disturb in anything.

regards,
keeshii

If you want to contact me quickly - send e-mail, not PM.
<?php $t='<?php $t=%c%s%c; printf($t,39,$t,39,10);%c'; printf($t,39,$t,39,10);

3

Re: login redirect (solved)

keeshii wrote:

I am sure, you have already found it, but just in case I will explain this to you.

You have to make modifications in login.php, directly above the hook 'li_login_pre_redirect'. Your code should looks like that:

        $expire = ($save_pass) ? time() + 1209600 : time() + $forum_config['o_timeout_visit'];
        forum_setcookie($cookie_name, base64_encode($user_id.'|'.$form_password_hash.'|'.$expire.'|'.sha1($salt.$form_password_hash.forum_hash($expire, $salt))), $expire);

        $_POST['redirect_url'] = 'https://google.com/'; /* <-- THIS LINE I HAVE ADDED */
        ($hook = get_hook('li_login_pre_redirect')) ? eval($hook) : null;
        redirect(forum_htmlencode($_POST['redirect_url']).((substr_count($_POST['redirect_url'], '?') == 1) ? '&amp;' : '?').'login=1', $lang_login['Login redirect']);

If you want to redirect to the main page of your domain, you should use "/" as address. fe. $_POST['redirect_url'] = '/'; After redirecting the parameter "login=1" will be attached, but this doesn't disturb in anything.

regards,
keeshii

thanks Keeshi