What is the best way to force users to the edit profile page.
Here is my code :
$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
}
I want to redirect users who's emails match that to force them to edit their profile the correct way to redirect them to the edit profile page is what I need to know.
Use the redirect()
method of the application object:
$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'
)
);
}