Joomla PHP如何以编程方式进入编辑个人资料页面

时间:2018-03-05 13:10:08

标签: php joomla

强制用户访问编辑个人资料页面的最佳方法是什么。

这是我的代码:

$user = JFactory::getUser();
if ($user->email === "fakemail@spam-disposable-domain.com") {
//Redirect user to the edit profile page forcing them to change their email.
//index.php?option=com_users&view=profile&layout=edit
}

我想重定向与电子邮件匹配的用户,强制他们编辑自己的个人资料,正确的方法是将其重定向到编辑个人资料页面,这是我需要知道的。

1 个答案:

答案 0 :(得分:1)

使用应用程序对象的redirect()方法:

$app  = JFactory::getApplication();
$user = JFactory::getUser();

if ($user->email === "fakemail@spam-disposable-domain.com")
{
    $app->enqueueMessage('Please change your email address!');
    $app->redirect(
        JRoute::_(
            'index.php?option=com_users&view=profile&layout=edit'
        )
    );
}
相关问题