Русское сообщество fluxbb

Быстрый лёгкий надёжный форумный движок

Вы не вошли.

Объявление

Вы можете внести свой вклад в содержание сайта. Жертвователи попадут в почетную группу "Спонсоры". Поддержать сайт.

#1 2017-04-13 13:49:32

gandi
Участник
Зарегистрирован: 2017-03-04
Сообщений: 19

How to redirect user to current page after log in via modal

I'm using modal for user log in, so the user can logging in without visiting login.php. I want to change the redirect setting for logging in. In another word, if I am a user and I'm curently reading certain topic then I'm interested to give comment about the topic. So I hit the login modal botton, but I don't want to be redirected to the index page after login, I need to be redirected to the topic that I'm curently read.
What sould i do?

Offline

#2 2017-04-13 16:05:41

Visman
Administrator
Из Сибирь
Зарегистрирован: 2009-06-08
Сообщений: 2,179
Сайт

Re: How to redirect user to current page after log in via modal

The code from the login.php file:
1. Redirect address calculation

// Try to determine if the data in HTTP_REFERER is valid (if not, we redirect to index.php after login)
if (!empty($_SERVER['HTTP_REFERER']))
	$redirect_url = validate_redirect($_SERVER['HTTP_REFERER'], null);

if (!isset($redirect_url))
	$redirect_url = get_base_url(true).'/index.php';
else if (preg_match('%viewtopic\.php\?pid=(\d+)$%', $redirect_url, $matches))
	$redirect_url .= '#p'.$matches[1];

2. Adding addresses to the form

<input type="hidden" name="redirect_url" value="<?php echo pun_htmlspecialchars($redirect_url) ?>" />

3. Go to the address after login

// Try to determine if the data in redirect_url is valid (if not, we redirect to index.php after login)
$redirect_url = validate_redirect($_POST['redirect_url'], 'index.php');

redirect(pun_htmlspecialchars($redirect_url), $lang_login['Login redirect']);

Offline

#3 2017-04-13 18:53:34

gandi
Участник
Зарегистрирован: 2017-03-04
Сообщений: 19

Re: How to redirect user to current page after log in via modal

Okay it's done now. Thanks mr Visman smile

Offline

Подвал доски

Под управлением FluxBB. Хостинг Hostens