Logout Trigger?

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