强制用户进入编辑个人资料页面的最佳方法是什么。
这是我的代码:
$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
}
我想重定向与电子邮件匹配的用户强制他们编辑他们的个人资料,正确的方式将他们重定向到编辑个人资料页面是我需要知道的。
使用应用程序对象的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'
)
);
}