Detect when someone logs out
BeantwortetI have created a Help Center home page for our company that is similar to the Zendesk Support page, where there are three icons, and clicking on the one labeled "Knowledge Base" opens up a box below on the same page that lists the docs and provides an "X" to collapes it. But I don't like how, when you follow a link to a document, and then go back to the home page, the list collapses automatically. I'd prefer it to remain open until the user explicitliy closes it. So I added a few jQuery lines to add a cookie to track the opened/closed state. However, if the user logs out and then logs back in a short time later, I'd like the page to always open in its initial state.
Is there a way I can detect that the user has logged out so I can delete my cookie at that point?
Thanks!
-
Hi Allen!
You should be able to achieve the effect by placing something like the following inside the
$(document).ready( function() {
block in your Help Center's JS tab:$("a[href\*='/access/logout']").on("click", function() { //your code to set cookie flag to 'collapsed' state });
This code will cause the 'Logout' link to run your click handler (to set the cookie info) before it runs the default handler that links to the logout page.
Hope this helps!
-Creighton -
My apologies for mistyping your name, Alan! Hopefully the solution makes up for it :)
-
No problem, Creighton, I bet you get that happening to you more often than I do :-)
I was away for the weekend and a PTO day yesterday, but this morning I tried your suggestion and it works like a top.
Simple and elegant solution, in retrospect I might have been able to think of that myself if I'd poked at it a little harder.
I had asked Zendesk Support the same question and they basically told me it couldn't be done. So I passed on your solution to them.
-
This thread has been closed for comments due to inactivity. Please start a new post if you have a question you'd like to ask the Community.
Post ist für Kommentare geschlossen.
4 Kommentare