com_users Logout Menu Item Type#7703
com_users Logout Menu Item Type#7703sanderpotjer wants to merge 4 commits intojoomla:stagingfrom sanderpotjer:com_users.logout
Conversation
There was a problem hiding this comment.
You're only using $app once. So a bit redundant to create a variable for it.
You can just do:
$params = JFactory::getApplication()->getMenu()->getActive()->params;
There was a problem hiding this comment.
Thanks for checking @nonumber. If we apply the if only once rule, it should even be like this right?
$itemid = JFactory::getApplication()->getMenu()->getActive()->params->get('logout');
|
Default logout page set to the homepage instead of current page. Usage of current page is not possible as that would be the logout page (results in loop). Default page makes more sense as well to prevent 404 errors on logout when logging out while being on a page that is only visible for registered users. |
|
Nice patch Sander! Works as expected! This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
Excellent new feature! No more having to use a 3pd extension to accomplish this task. Tested and found to work great. |
|
Tested. All good! |
|
@brianteeman Can we get your language review? If you are ok with it we can set it RTC ;) Thanks for all the testers and @sanderpotjer 😄 |
|
Quote: "Provide a title and typically you would set the Access to "Registered" so only logged-in users can see the logout menu-item." The other way around: Is there a way to hide a login menu-item for registered users, when the have logged in? When using a login menu-item and a logout menu-item both menu-items are visible after a successful login. Ideally only the logout menu-item should be visible. |
|
@waader yes you can hide login items for users who are logged in. See On 17 August 2015 at 19:33, waader notifications@github.com wrote:
Brian Teeman |
|
one more successful test - Thanks This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
There was a problem hiding this comment.
This only gets the Itemid of the menu item to redirect to. It doesn't collect the full url.
Shouldn't this be something like this?
$url = $itemid
? JFactory::getApplication()->getMenu()->getItem($itemid)->link
: JURI::root();
(Haven't tested this. Don't know if it is correct syntax to get menu url).
There was a problem hiding this comment.
The full url is not needed as that is handled (JRoute) by the logout() method of UsersControllerUser. Exactly the same happens right now for the mod_login module.
|
@brianteeman Thanks for the hint! |
|
Thanks all for your feedback & testing! |
|
All good. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
@brianteeman can we RTC or do we need language changes? |
|
Everything worked well! This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
@test The logout-option is very easy and fast to be set up. Successful test and nice patch This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
Create a new Menu-Item -> Users -> Logout and let the Default-Option. Logged in as Administrator and it Works. Very cool and easy to use. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
@test success, after applying the patch I can see a new "Logout" option for com_users, creating a menu item as described and clicking on it after I've logged in, the logout went fine. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
I have missed this so many times. Thanks! Works as expected. |
|
Perfect. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
I have tested this item ✅ successfully on 1d8e29c This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
Worked as expected This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
I have tested this item ✅ successfully on 1d8e29c This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703. |
|
Thanks @sanderpotjer merged into 3.5-dev with commit 489fb6 |
|
Thanks @roland-d and all testers! |
This Pull Requests adds a new Menu Item Type "Logout" to the available menu item types. It allows users to create a menu item "Logout" that directly logouts a user when clicking on the menu item. Optionally you can set a page to redirect after logout, otherwise the user will be redirected to the default (home) page.
In this way it is no longer needed to use the "Login" menu-item type to logout, which shows a page with a "Logout" button only.
For the
JFIELD_LOGOUT_REDIRECT_PAGE_DESCandJFIELD_LOGOUT_REDIRECT_PAGE_LABELthe same description is used as for the mod_login with the similar functionality (MOD_LOGIN_FIELD_LOGOUT_REDIRECTURL_DESCandMOD_LOGIN_FIELD_LOGOUT_REDIRECTURL_LABEL).Test instructions
After applying the patch you can create a new menu-item from type "Logout"

Provide a title and typically you would set the Access to "Registered" so only logged-in users can see the logout menu-item.
Optionally you can select a "Logout Redirection Page" under "Options" that will be used to redirect the user to after logout. "Default" will return to the default (home) page.

Save the menu item and login with a user on the frontend of the website. The logout menu item should be visible. Clicking on the logout menu item should end your user session and redirect to the page set.