How to create logout link in Joomla 1.7
Joomla 1.7 Logout link
Its very simple to create logout link in joomla 1.7. You can create it in your extensions as shown below.
<?php $token = JUtility::getToken(); $linkout = JRoute::_("index.php?option=com_users&task=user.logout&".$token."=1"); ?> <a href="<?php echo $linkout; ?>"> Logout </a>How to redirect user on a particular link after logout in Joomla 1.7?
If you want to redirect Joomla user on a link not on home page then use the following code.
<?php $url = JRoute::_(JURI::Base().'index.php?option=com_users'); // here i'm redirecting to login view. ?> <a href="index.php?option=com_users&task=user.logout&<?php echo JUtility::getToken(); ?>=1&return=<?php echo base64_encode($url); ?>">Logout</a>How to create logout menu item for Joomla 1.7 ?
To create a menu-item for logout in Joomla 1.7. You should add task in either your custom component.
Paste this code in your components controller file. Add a new menu item as Sytem link, external url & add your task url in link. like index.php?option=com_YOUR_COMPONENT_NAME&task=logout
function logout()However you achive this by using plugin.
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$user_id = $user->get($user->id);
$app->logout($user_id, array());
$app->redirect(JURI::base()); // you can redirect anywhere
}
Your are welcome Arif
ReplyDeleteGreat, thanks to share a article that included whatever required a user.
ReplyDeletejoomla developer
Thanks alot, Very helpful :)
ReplyDeleteAlways welcome Kazim..
ReplyDeleteThanks.
ReplyDeleteThank you.
ReplyDeleteI wanted to thank you for this excellent read!! I certainly enjoyed every little bit of it.
ReplyDeleteI have got you bookmarked to look at new stuff you post…