Skip to content

Редирект со страницы регистрации и входа

Здравствуйте, подскажите, пожалуйста, как сделать, чтобы зарегистрированных пользователей редиректило со страницы регистрации, входа и восстановления пароля, если они туда случайно зашли по ссылке?

 

Сейчас, если перейти по этим ссылкам

 

форум.ru/index.php?app=core&module=global&section=login

форум.ru/index.php?app=core&module=global&section=register

форум.ru/index.php?app=core&module=global&section=lostpass

 

авторизованным пользователем, он попадает на эти страницы. Хотелось бы, чтобы его редиректило на главную.

 

Т.е. чтобы эти страницы были доступны только гостям.

Edited by Strategius

Featured Replies

  • Author

Получилось добавить редирект на главную страницу.

 

Для регистрации admin\applications\core\modules_public\global\register.php

 

После:

 

IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW ) ) );

Добавил:

 

/* Редирект авторизованного пользователя на главную страницу */
$this->registry->getClass('output')->redirectScreen( $return[0], $this->registry->output->formatUrl( $this->settings['board_url'] ) );

 

Для входа admin\applications\core\modules_public\global\login.php

 

После

 

$template .= $this->registry->getClass('output')->getTemplate('login')->errors($message);
	}

Добавил

 

/* Редирект авторизованного пользователя на главную страницу */
if ($this->memberData['member_id'])
  {
  $this->registry->getClass('output')->redirectScreen( $return[0], $this->registry->output->formatUrl( $this->settings['board_url'] ) );
  }

Но насколько ли правильное это решение, и разумное ли оно вообще?

 

Для восстановления пароля admin\applications\core\modules_public\global\lostpass.php составил такую функцию:

 

protected function _avMemberRed()
{
  /* Редирект авторизованного пользователя на главную страницу */
    if ($this->memberData['member_id'])
       {
       $this->registry->getClass('output')->redirectScreen( $return[0], $this->registry->output->formatUrl( $this->settings['board_url'] ) );
       }
}

Но она почему-то не работает...

Edited by Strategius

  • Author

Кстати, чем отличается $this->registry->getClass('output')->silentRedirect от $this->registry->getClass('output')->redirectScreen?

Кстати, чем отличается $this->registry->getClass('output')->silentRedirect от $this->registry->getClass('output')->redirectScreen?

Во втором случае после редиректа появляется сообщение.

  • Author

@newbie, понял, спасибо!

 

Для добавления редиректа на страницу восстановления пароля в файле admin\applications\core\modules_public\global\lostpass.php

 

После

 

if ( $this->settings['bot_antispam_type'] != 'none' )
	{
		$this->output = str_replace( "<!--{REG.ANTISPAM}-->", $captchaHTML, $this->output );
	}

Добавляем

 

/* Редирект авторизованного пользователя на главную страницу */
       if ($this->memberData['member_id'])
       {
          $this->registry->getClass('output')->silentRedirect( $this->registry->output->formatUrl( $this->settings['board_url'] ) );
       }

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.