Skip to content

com_users Logout Menu Item Type#7703

Closed
sanderpotjer wants to merge 4 commits intojoomla:stagingfrom
sanderpotjer:com_users.logout
Closed

com_users Logout Menu Item Type#7703
sanderpotjer wants to merge 4 commits intojoomla:stagingfrom
sanderpotjer:com_users.logout

Conversation

@sanderpotjer
Copy link
Copy Markdown
Member

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_DESC and JFIELD_LOGOUT_REDIRECT_PAGE_LABEL the same description is used as for the mod_login with the similar functionality (MOD_LOGIN_FIELD_LOGOUT_REDIRECTURL_DESC and MOD_LOGIN_FIELD_LOGOUT_REDIRECTURL_LABEL).

Test instructions

After applying the patch you can create a new menu-item from type "Logout"
screen shot 2015-08-16 at 20 24 48

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.
screen shot 2015-08-16 at 20 29 18

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.

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-staging labels Aug 16, 2015
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');

@zero-24 zero-24 added this to the Joomla! 3.5.0 milestone Aug 17, 2015
@sanderpotjer
Copy link
Copy Markdown
Member Author

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.

@RickR2H
Copy link
Copy Markdown
Member

RickR2H commented Aug 17, 2015

Nice patch Sander! Works as expected!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703.

@justinherrin
Copy link
Copy Markdown
Contributor

Excellent new feature! No more having to use a 3pd extension to accomplish this task.

Tested and found to work great.

@peterlose
Copy link
Copy Markdown
Contributor

Tested. All good!

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Aug 17, 2015

@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 😄

@waader
Copy link
Copy Markdown
Contributor

waader commented Aug 17, 2015

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.

@brianteeman
Copy link
Copy Markdown
Contributor

@waader yes you can hide login items for users who are logged in. See
https://brian.teeman.net/joomla/415-the-guest-user-group-hiding-menu-items-and-modules

On 17 August 2015 at 19:33, waader notifications@github.com wrote:

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.


Reply to this email directly or view it on GitHub
#7703 (comment).

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

@MATsxm
Copy link
Copy Markdown

MATsxm commented Aug 17, 2015

one more successful test - Thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok :)

@waader
Copy link
Copy Markdown
Contributor

waader commented Aug 17, 2015

@brianteeman Thanks for the hint!

@sanderpotjer
Copy link
Copy Markdown
Member Author

Thanks all for your feedback & testing!

@alimpam
Copy link
Copy Markdown

alimpam commented Aug 20, 2015

All good.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703.

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Aug 20, 2015

@brianteeman can we RTC or do we need language changes?

@kathastaden
Copy link
Copy Markdown

Everything worked well!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703.

@Teck95
Copy link
Copy Markdown

Teck95 commented Aug 20, 2015

@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.

@hitchblade
Copy link
Copy Markdown

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.

@watchfulli-dev
Copy link
Copy Markdown

@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.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 21, 2015
@bullet64
Copy link
Copy Markdown

I have missed this so many times. Thanks!

Works as expected.

@SiteOp
Copy link
Copy Markdown

SiteOp commented Sep 10, 2015

Perfect.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703.

@dam-man
Copy link
Copy Markdown
Contributor

dam-man commented Oct 10, 2015

I have tested this item ✅ successfully on 1d8e29c

Nobody clicked the "Tested Succesfully" button so it won't be completed.
Nice option Sander 😄


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703.

@willoweb
Copy link
Copy Markdown

Worked as expected
Thanks Sander


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703.

@crommie
Copy link
Copy Markdown

crommie commented Oct 10, 2015

I have tested this item ✅ successfully on 1d8e29c

Works.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7703.

roland-d pushed a commit that referenced this pull request Oct 17, 2015
@roland-d
Copy link
Copy Markdown
Contributor

Thanks @sanderpotjer merged into 3.5-dev with commit 489fb6

@roland-d roland-d closed this Oct 17, 2015
@sanderpotjer
Copy link
Copy Markdown
Member Author

Thanks @roland-d and all testers!

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Oct 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.