简体   繁体   English

将登录的用户重定向到joomla中的页面

[英]redirect a logged user to a page in joomla

I'm doing a form in more page on joomla. 我正在joomla的更多页面中执行表单。

I'd like to do a thing 我想做一件事

The user log-in the site. 用户登录站点。 Complete the first page of the form, after when insert the data e click on a button I will be redirect to another page of the form 填写表格的第一页,在插入数据后,单击一个按钮,我将被重定向到表格的另一页

I tried this code 我尝试了这段代码

$user = JFactory::getUser();
  $id = $user->get('id');
if(isset($_SESSION['id']))
{
header("Location: http://www.mysite/second-page-form");
exit;
}

But it doesn't work 但这不起作用

I can solve it? 我能解决吗?

Try the following, it will set the location header of the response to the location of your second page: 尝试以下操作,它将响应的location标题设置为第二页的位置:

if($user->id)
{
    header("Location: http://www.mysite/second-page-form");
    exit;
}

You do not need to check for the session. 您无需检查会话。 You can simply detect if the user is logged in: 您可以简单地检测用户是否登录:

$user = JFactory::getUser();
$app  = JFactory::getApplication();
if(!$user->guest)
{
    $app->redirect(JRoute::_('URL GOES HERE STARTING WITH index.php'), false);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM