I’m attempting to write a function that will log the user out if they meet specific criteria. I’ve got it all working up to the logout part. I attempted to use .trigger and .click to click the logout link on render but that’s buggy and isn’t working consistently. Is there a Knack trigger to log a user out without clicking the “logout” link/button?
Hi Travis,
Is this what you’re looking for?
Knack.user.destroy()
It also accepts a success callback, if you want to run code when the log out is successful:
Knack.user.destroy({
success: function() {
// code to run after log out
console.log('log out was successful')
}
})
Hope that helps.
Ian
Knack Pros
2 Likes
Thank you Ian! That is exactly what I was looking for. Also, thank you for adding the extra tip about the callback.
1 Like
@KnackPros Have you ever tested Knack.user.destroy
in an embedded app? When I’ve tried, it doesn’t seem to trigger when run from the embed, but works when under the Knack domain.
@StephenChapman Seeing the same result as you.
1 Like