Redirect to Portal not Index after Login

Current Version: 2.1.0
Released: 2015-10-26
Forum rules
Before creating a new support thread, please take a look at the board3 Portal FAQ and use the search!
Many questions have already been answered.
Locked

Topic author
ohockey
Active Member
Posts: 4
Joined: 11. December 2014 21:05

Redirect to Portal not Index after Login

Post by ohockey »

Your Portal Version: 2.1.0-RC1
Your phpBB Type: Standard phpBB3
MODs installed: No
Your knowledge: Beginner
Boardlink: http://hockeytime.cu.cc

What have you done before the problem was there?
Nothing

What have you already tryed to solve the problem?
Tried modifying ucp.php but it did not work

Description and Message
After login I would like users redirected to the portal page not the index page. Ideally, I would like the same after they logout as well.

Topic author
ohockey
Active Member
Posts: 4
Joined: 11. December 2014 21:05

Re: Redirect to Portal not Index after Login

Post by ohockey »

I want to have the portal the default after login and logout. I currently use a redirect so users see the portal after going to my website. I tried modifying as suggested, even though my portal.php file is different. I get the error:

No route found for "GET /portal.php"

Can you tell me what is wrong?

Code: Select all

My original file looks like the following:
// Basic "global" modes
switch ($mode)
{
	case 'activate':
		$module->load('ucp', 'activate');
		$module->display($user->lang['UCP_ACTIVATE']);

		redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
	break;

	case 'resend_act':
		$module->load('ucp', 'resend');
		$module->display($user->lang['UCP_RESEND']);
	break;

	case 'sendpassword':
		$module->load('ucp', 'remind');
		$module->display($user->lang['UCP_REMIND']);
	break;

	case 'register':
		if ($user->data['is_registered'] || isset($_REQUEST['not_agreed']))
		{
			redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
		}

		$module->load('ucp', 'register');
		$module->display($user->lang['REGISTER']);
	break;

	case 'confirm':
		$module->load('ucp', 'confirm');
	break;

	case 'login':
		if ($user->data['is_registered'])
		{
			redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
		}

		login_box(request_var('redirect', "index.$phpEx"));
	break;

	case 'login_link':
		if ($user->data['is_registered'])
		{
			redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
		}

		$module->load('ucp', 'login_link');
		$module->display($user->lang['UCP_LOGIN_LINK']);
	break;

	case 'logout':
		if ($user->data['user_id'] != ANONYMOUS && $request->is_set('sid') && $request->variable('sid', '') === $user->session_id)
		{
			$user->session_kill();
		}
		else if ($user->data['user_id'] != ANONYMOUS)
		{
			meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));

			$message = $user->lang['LOGOUT_FAILED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
			trigger_error($message);
		}

		redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
	break;

	case 'terms':
	case 'privacy':

		$message = ($mode == 'terms') ? 'TERMS_OF_USE_CONTENT' : 'PRIVACY_POLICY';
		$title = ($mode == 'terms') ? 'TERMS_USE' : 'PRIVACY';

		if (empty($user->lang[$message]))
		{
			if ($user->data['is_registered'])
			{
				redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
			}

			login_box();
		}

		$template->set_filenames(array(
			'body'		=> 'ucp_agreement.html')
		);

		// Disable online list
		page_header($user->lang[$title]);

		$template->assign_vars(array(
			'S_AGREEMENT'			=> true,
			'AGREEMENT_TITLE'		=> $user->lang[$title],
			'AGREEMENT_TEXT'		=> sprintf($user->lang[$message], $config['sitename'], generate_board_url()),
			'U_BACK'				=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
			'L_BACK'				=> $user->lang['BACK_TO_LOGIN'],
		));

		page_footer();

	break;




My changed version is this:

// Basic "global" modes
switch ($mode)
{
	case 'activate':
		$module->load('ucp', 'activate');
		$module->display($user->lang['UCP_ACTIVATE']);

		redirect(append_sid("{$phpbb_root_path}portal.$phpEx"));
	break;

	case 'resend_act':
		$module->load('ucp', 'resend');
		$module->display($user->lang['UCP_RESEND']);
	break;

	case 'sendpassword':
		$module->load('ucp', 'remind');
		$module->display($user->lang['UCP_REMIND']);
	break;

	case 'register':
		if ($user->data['is_registered'] || isset($_REQUEST['not_agreed']))
		{
			redirect(append_sid("{$phpbb_root_path}portal.$phpEx"));
		}

		$module->load('ucp', 'register');
		$module->display($user->lang['REGISTER']);
	break;

	case 'confirm':
		$module->load('ucp', 'confirm');
	break;

	case 'login':
		if ($user->data['is_registered'])
		{
			redirect(append_sid("{$phpbb_root_path}portal.$phpEx"));
		}

		login_box(request_var('redirect', "portal.$phpEx"));
	break;

	case 'login_link':
		if ($user->data['is_registered'])
		{
			redirect(append_sid("{$phpbb_root_path}portal.$phpEx"));
		}

		$module->load('ucp', 'login_link');
		$module->display($user->lang['UCP_LOGIN_LINK']);
	break;

	case 'logout':
		if ($user->data['user_id'] != ANONYMOUS && $request->is_set('sid') && $request->variable('sid', '') === $user->session_id)
		{
			$user->session_kill();
		}
		else if ($user->data['user_id'] != ANONYMOUS)
		{
			meta_refresh(3, append_sid("{$phpbb_root_path}portal.$phpEx"));

			$message = $user->lang['LOGOUT_FAILED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
			trigger_error($message);
		}

		redirect(append_sid("{$phpbb_root_path}portal.$phpEx"));
	break;

	case 'terms':
	case 'privacy':

		$message = ($mode == 'terms') ? 'TERMS_OF_USE_CONTENT' : 'PRIVACY_POLICY';
		$title = ($mode == 'terms') ? 'TERMS_USE' : 'PRIVACY';

		if (empty($user->lang[$message]))
		{
			if ($user->data['is_registered'])
			{
				redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
			}

			login_box();
		}

		$template->set_filenames(array(
			'body'		=> 'ucp_agreement.html')
		);

		// Disable online list
		page_header($user->lang[$title]);

		$template->assign_vars(array(
			'S_AGREEMENT'			=> true,
			'AGREEMENT_TITLE'		=> $user->lang[$title],
			'AGREEMENT_TEXT'		=> sprintf($user->lang[$message], $config['sitename'], generate_board_url()),
			'U_BACK'				=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
			'L_BACK'				=> $user->lang['BACK_TO_LOGIN'],
		));

		page_footer();

	break;
User avatar

Kirk
Dev
Posts: 1956
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: Redirect to Portal not Index after Login

Post by Kirk »

Hi
Open: root/ucp.php
Find:

Code: Select all

	case 'login':
		if ($user->data['is_registered'])
		{
			redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
		}

		login_box(request_var('redirect', "index.$phpEx"));
	break;
Replace with:

Code: Select all

	case 'login':
		if ($user->data['is_registered'])
		{
			redirect(append_sid("{$phpbb_root_path}app.$phpEx/portal"));
		}

		login_box(request_var('redirect', "app.$phpEx/portal"));
	break;
Find:

Code: Select all

	case 'logout':
		if ($user->data['user_id'] != ANONYMOUS && $request->is_set('sid') && $request->variable('sid', '') === $user->session_id)
		{
			$user->session_kill();
		}
		else if ($user->data['user_id'] != ANONYMOUS)
		{
			meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));

			$message = $user->lang['LOGOUT_FAILED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
			trigger_error($message);
		}

		redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
	break;
Inline find:

Code: Select all

redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
Replace with:

Code: Select all

redirect(append_sid("{$phpbb_root_path}app.$phpEx/portal"));
Gruß Udo

Topic author
ohockey
Active Member
Posts: 4
Joined: 11. December 2014 21:05

Re: Redirect to Portal not Index after Login

Post by ohockey »

Thank you for the quick reply. Before I get started, the 2nd find you listed does not have the equivalent replace statement that I believe should be listed. Could you please provide or explain if I am incorrect.
User avatar

Kirk
Dev
Posts: 1956
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: Redirect to Portal not Index after Login

Post by Kirk »

Sorry i can not translate this message.
The changes are all in the root/ucp.php.
Gruß Udo

thirdoff
Active Member
Posts: 1
Joined: 22. October 2014 11:29
phpBB.de User: thirdoff
phpBB.com User: thirdoff

Re: Redirect to Portal not Index after Login

Post by thirdoff »

How to redirect to portal all the time, even when not logged in?
Locked

Return to “Board3 Portal 2.1.x - English Support”