Kevin,
If you really want to have a logout page, then here is how to achieve that. Add a public page called Logout or whatever, and ensure it is set with none of the options ticked:
On the Logout page, add a Rich Text view and a Menu view. The menu view should have one button, which directs to your existing home page, and is labelled Log In. This will kick users back to the Log In page if they wish. Add some instructions in the Rich text view, like below:
Now add some Javascript to completely hijack the Knack LOG OUT link, to direct the user to this new logout page. Note it does NOT actually log the user out - it just sends them to a “dead end” page. (Note this is edited from the original post because the original didn’t work as expected)
(function hijackLogoutLink() {
// Run once, keep watching
setInterval(() => {
const $logout = $('a.kn-log-out');
const $custom = $('#custom-logout-link');
if ($logout.length && $custom.length === 0) {
const $customLink = $('<a href="#" id="custom-logout-link">Log Out</a>');
$logout.replaceWith($customLink);
}
}, 500);
// Redirect when custom link is clicked
$(document).on('click', '#custom-logout-link', function (e) {
e.preventDefault();
window.location.href = 'https://XXX.knack.com/YYY#logout-page/';
});
})();
where XXX and YYY are appropriate for your app - i.e use the url of the newly created logout page
and add the following javascript to remove the Info bar from that logout page
$(document).on('knack-view-render.view_776', function(event, view, data) {
setTimeout(function() {
$('#knack-dist_1 > div.kn-info-bar').hide();
}, 200);
});
The view_776 will need to be adjusted for whatever the Rich text view on your logout page is.
And that should do it - when they log out they will see something like this:
As I said above, they aren’t really logged out but they are sitting on a “dead end” page with only one option - to “log in” again. (or close the browser)
Hope that is helpful?