Joomla Redirect User With Code

This tutorial I will show you how to redirect users in your custom Joomla component. You can also send a message such as a success, warning, info.

In your component, add the following codes


// Get current application
$app = JFactory::getApplication();

// set your message
JFactory::getApplication()->enqueueMessage(JText::_('This is an error message!'), 'error');

// redirect to url
$app->redirect(JRoute::_('index.php?option=com_users&view=login'));

In my example I am redirecting the user to the login page with an error message, of course you can redirect to any page using this code.

That’s it. I hope you find this useful, leave a comment.

Please Post Your Comments & Reviews

Welcome to Western Studios

We provide professional website and mobile softwares including Joomla, Wordpress and more.