# Logout Trigger?

**URL:** <https://forums.knack.com/t/logout-trigger/12274>\
**Category:** Ask Developers\
**Created:** [March 23, 2022, 2:40pm UTC](https://forums.knack.com/t/logout-trigger/12274 "2022-03-23T14:40:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Travis](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@Travis](https://forums.knack.com/u/Travis)\
**Post date:** [March 23, 2022, 2:40pm UTC](https://forums.knack.com/t/logout-trigger/12274/1 "2022-03-23T14:40:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![KnackPros](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/knackpros/32/807_2.png) [@KnackPros](https://forums.knack.com/u/KnackPros)\
**Post date:** [March 24, 2022, 12:01am UTC](https://forums.knack.com/t/logout-trigger/12274/2 "2022-03-24T00:01:38Z")

</div>

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:

```auto
Knack.user.destroy({
  success: function() {
    // code to run after log out
    console.log('log out was successful')
  }
})

```

Hope that helps.

Ian  
[Knack Pros](https://knackpros.com)

---

<div class="post-metadata">

**Author:** ![Travis](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@Travis](https://forums.knack.com/u/Travis)\
**Post date:** [March 30, 2022, 3:39pm UTC](https://forums.knack.com/t/logout-trigger/12274/3 "2022-03-30T15:39:50Z")

</div>

Thank you Ian! That is exactly what I was looking for. Also, thank you for adding the extra tip about the callback.

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [July 21, 2024, 11:48pm UTC](https://forums.knack.com/t/logout-trigger/12274/4 "2024-07-21T23:48:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KnackPros](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/knackpros/32/807_2.png) [@KnackPros](https://forums.knack.com/u/KnackPros)\
**Post date:** [July 29, 2024, 11:20pm UTC](https://forums.knack.com/t/logout-trigger/12274/5 "2024-07-29T23:20:25Z")

</div>

@StephenChapman Seeing the same result as you.
