所以我有以下代码导致无限重定向循环,因为我无法检查用户所在的当前URL是否是“com_users”组件。
如果它们在com_users组件上,我不希望再执行任何代码。
public function onAfterInitialise() {
$app = JFactory::getApplication();
$user = JFactory::getUser();
if (!$user->guest) {
//THIS CAN'T GET CURRENT COMPONENT AND CAUSES INFINITE redirect LOOP
if ( !($app->input->get('option') == 'com_users' && JRequest::getVar('view') == 'profile') ) { //IF NOT on the EDIT PROFILE URL then force the user to go and change their email
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'
)
);
}
}
}
}
答案 0 :(得分:1)
使用观察者来降低复杂性。
不推荐使用 Duration = [DeliveryDate] - RELATED(Delivery[OrderDate])
,而是使用JRequest
。
$app->input
做了一些自动卫生。
Input::getCmd()