# Staged users disappearing?

**URL:** https://meta.discourse.org/t/staged-users-disappearing/87442
**Category:** Bug
**Created:** [May 14, 2018, 3:33pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442 "2018-05-14T15:33:37Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [May 14, 2018, 3:33pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/1 "2018-05-14T15:33:37Z")

</div>

Is it possible that staged users are deleted automatically after a while, if they don’t reply? This seems to have happened on my site with a handful of staged users from over a month ago - maybe 15 of them. I have been using staged users as part of my effort to [use discourse as a ticket system](https://meta.discourse.org/t/using-discourse-as-ticket-system-so-no-balls-are-dropped-woman-juggling/82698), but now I am finding that the people I was writing to are gone and the messages are just to myself and there is no sign of the staged user, in the message or in the user list. I can confirm in mandrill that the email notifications were sent to the email address of the staged user.

Any insights much appreciated. 🌱

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 14, 2018, 5:23pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/2 "2018-05-14T17:23:02Z")

</div>

Yes, [we’ll automatically remove](https://github.com/discourse/discourse/blob/master/app/jobs/scheduled/clean_up_unused_staged_users.rb) any staged users created more than 1 year ago and who have never posted.

You should see them in the staff action logs (“delete user” action).

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [May 14, 2018, 5:26pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/3 "2018-05-14T17:26:47Z")

</div>

Thanks, Regis! Is there an admin setting to disable this feature? I’d like to not delete them automatically. If there is none (and I couldn’t find one) could you contemplate adding it?

When they are deleted, is any shadow of a trace left behind, for example in any messages they have been in? It’s really weird to me to see messages I have written to people who are no longer in the message. Now it looks like I am schizophrenic, talking to myself and giving myself all kinds of interesting names. 😉

Also, I think something went wrong in this case because these staged users I am talking about were created more recently, like in the last few weeks and months. None of them were created more than 1 year ago.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 14, 2018, 5:30pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/4 "2018-05-14T17:30:59Z")

</div>

> [@tobiaseigen](#):
>
> Thanks, Regis! Is there an admin setting to disable this feature? I’d like to not delete them automatically. If there is none (and I couldn’t find one) could you contemplate adding it?

I could add a setting.

> [@tobiaseigen](#):
>
> When they are deleted, is any shadow of a trace left behind, for example in any messages they have been in? It’s really weird to me to see messages I have written to people who are no longer in the message. Now it looks like I am schizophrenic, talking to myself and giving myself all kinds of interesting names. 😉

They’re deleted as if you clicked the Delete User button in the user admin page so standard deletion rules apply.

> [@tobiaseigen](#):
>
> Also, I think something went wrong in this case because these staged users I am talking about were created more recently, like in the last few weeks and months. None of them were created more than 1 year ago.

The code looks good to me. Would ❤ to get more info or (even better) reproduction steps 😉

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [May 14, 2018, 5:37pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/6 "2018-05-14T17:37:46Z")

</div>

Please do add a setting when you get a chance - this is really causing me problems. I don’t know how to replicate, but I can see that starting 27 days ago, discourse has been deleting staged users and I’m now up to 24 users deleted. Here are some examples deleted today - I replaced usernames with ` **DELETED** `. They all seem to be 14 days old when they are deleted.

```
id: 4912
username: **DELETED**
name: **DELETED**
created_at: 2018-04-30 03:39:26 UTC
trust_level: 0
last_seen_at: 
last_emailed_at: 2018-05-10 11:40:53 UTC

id: 4911
username: **DELETED**
name: **DELETED**
created_at: 2018-04-30 03:31:20 UTC
trust_level: 0
last_seen_at: 
last_emailed_at: 2018-04-30 03:41:28 UTC

```

Could it be I am running afoul of the “purge unactivated users grace period days” setting? It was set to 14 days, and I have now set it to zero.

![30%20AM](https://global.discourse-cdn.com/meta/optimized/3X/6/e/6e9487f5d72a6b7555cdf5bd7ec8a983fd90e712_2_690x80.png)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 14, 2018, 6:17pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/7 "2018-05-14T18:17:31Z")

</div>

> [@tobiaseigen](#):
>
> Could it be I am running afoul of the “purge unactivated users grace period days” setting?

Most definitely. That setting controls a purge of [**all** inactive users](https://github.com/discourse/discourse/blob/b004503c6279e9939bc8613fe6d57447a95343de/app/models/user.rb#L1246-L1263).

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [May 14, 2018, 6:30pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/8 "2018-05-14T18:30:46Z")

</div>

> [@zogstrip](#):
>
> Most definitely. That setting controls a purge of [**all** inactive users](https://github.com/discourse/discourse/blob/b004503c6279e9939bc8613fe6d57447a95343de/app/models/user.rb#L1246-L1263).

`*phew*` that’s great to learn. Seems to me though that staged users should be excluded from that setting.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 14, 2018, 10:05pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/9 "2018-05-14T22:05:45Z")

</div>

I’m pretty sure these are completely unrelated things.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 15, 2018, 2:34am UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/10 "2018-05-15T02:34:44Z")

</div>

Yeah, so that has been running against staged users this whole time, but it hasn’t been catching any of them because in every _other_ usage of staged users, all the ones that are cared about have at least one post (the initial e-mail)!

The setting has been deleting things like, “someone adds a CC to a staged-user-based support PM, they get invited, never say anything” → 🗑

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 15, 2018, 3:52am UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/11 "2018-05-15T03:52:36Z")

</div>

> [@riking](#):
>
> in every _other_ usage of staged users, all the ones that are cared about have at least one post (the initial e-mail)!

LOL, go figure! 😺

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [May 15, 2018, 3:26pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/12 "2018-05-15T15:26:45Z")

</div>

thanks, all. the explanation makes good sense to me.

so where am I at with this? is disabling the 14 day purge of unactivated users going to fix my problem?

will you change it so in future staged users are not deleted by the 14 day purge?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 15, 2018, 11:07pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/13 "2018-05-15T23:07:37Z")

</div>

> [@riking](#):
>
> The setting has been deleting things like, “someone adds a CC to a staged-user-based support PM, they get invited, never say anything” -\> 🗑

Possibly, what are your thoughts on this @sam?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 16, 2018, 12:13am UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/14 "2018-05-16T00:13:34Z")

</div>

The trivial fix here is to look at `topic_allowed_users` before doing the great 14 day purge… cause the users have records there and should be left alone. Marking this as a bug… already assigned to @zogstrip who can sort it out.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 16, 2018, 4:25pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/15 "2018-05-16T16:25:29Z")

</div>

@tobiaseigen it’s now fixed 🍒

[https://github.com/discourse/discourse/commit/39aceed63d4b03da41b21d7150b998e50be57a59](https://github.com/discourse/discourse/commit/39aceed63d4b03da41b21d7150b998e50be57a59)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 17, 2018, 4:00pm UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/16 "2018-05-17T16:00:01Z")

</div>

This topic was automatically closed after 23 hours. New replies are no longer allowed.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [June 29, 2018, 7:40am UTC](https://meta.discourse.org/t/staged-users-disappearing/87442/17 "2018-06-29T07:40:52Z")

</div>

@codinghorror recently noticed that old inactive users were not getting purged. Turns out this was because the inactive users had a welcome message from discobot which prevented them from getting purged.

We will now purge inactive users even if they have a message from _non-human_ users (system, discobot) as per:

[https://github.com/discourse/discourse/commit/7550e9ff958d13465d0382f6daab193ff5eda7fb](https://github.com/discourse/discourse/commit/7550e9ff958d13465d0382f6daab193ff5eda7fb)
