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

问题描述 投票:0回答:1

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

这是我的代码:

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

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

php joomla
1个回答
1
投票

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

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

if ($user->email === "[email protected]")
{
    $app->enqueueMessage('Please change your email address!');
    $app->redirect(
        JRoute::_(
            'index.php?option=com_users&view=profile&layout=edit'
        )
    );
}
© www.soinside.com 2019 - 2024. All rights reserved.