# Batch unhide posts

**URL:** https://meta.discourse.org/t/batch-unhide-posts/27716
**Category:** Support
**Created:** [April 17, 2015, 10:02pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716 "2015-04-17T22:02:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![NomNuggetNom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nomnuggetnom/32/122685_2.png) [@NomNuggetNom](https://meta.discourse.org/u/NomNuggetNom)
#### Post date: [April 17, 2015, 10:02pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/1 "2015-04-17T22:02:46Z")

</div>

We made a tiny mistake on our instance where we set a user to trust level 0. This hid all of their posts… Any way to automatically unhide them now? There are thousands of posts, so doing it manually is out of the question. Thanks.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [April 17, 2015, 10:05pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/2 "2015-04-17T22:05:07Z")

</div>

Were all the posts in categories that require \> TL0 ?

---

<div class="post-metadata">

### Author: ![NomNuggetNom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nomnuggetnom/32/122685_2.png) [@NomNuggetNom](https://meta.discourse.org/u/NomNuggetNom)
#### Post date: [April 17, 2015, 10:07pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/3 "2015-04-17T22:07:24Z")

</div>

I don’t think so. But the default trust level for our users is trust level one.

---

<div class="post-metadata">

### Author: ![FHTzoob](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fhtzoob/32/37485_2.png) [@FHTzoob](https://meta.discourse.org/u/FHTzoob)
#### Post date: [April 17, 2015, 10:19pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/4 "2015-04-17T22:19:36Z")

</div>

Yeah hi that user was me… My trust level was set to 0, and there were about 5000 posts, so doing it manually is out of the question. 😕 @codinghorror @sam

---

<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: [April 17, 2015, 10:28pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/5 "2015-04-17T22:28:35Z")

</div>

> [@NomNuggetNom](#):
>
> the default trust level for our users is trust level one

This is a bad idea, and I strongly advise against this. TL0 has important spam protection. You are opening yourself up to a lot of spam with TL1 default.

I just added this to the site setting description:

> Default trust level (0-4) for all new users. **WARNING! Changing this will put you at serious risk for spam.**

---

<div class="post-metadata">

### Author: ![NomNuggetNom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nomnuggetnom/32/122685_2.png) [@NomNuggetNom](https://meta.discourse.org/u/NomNuggetNom)
#### Post date: [April 17, 2015, 10:42pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/6 "2015-04-17T22:42:02Z")

</div>

That’s not the issue we’re having (nor have we had that issue in the past). We use SSO which requires a different sign up method, so we don’t get spam bots or anything. Anyway, this is a topic for another time 😛

---

<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: [April 17, 2015, 10:43pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/7 "2015-04-17T22:43:01Z")

</div>

OK cool, with SSO enabled it is _probably_ safe, but we have seen sites with bad login protections (no captcha, no email verification, etc) do much worse with SSO enabled. We’ve had to go back and enable many spam protections that we normally disable with SSO turned on.

---

<div class="post-metadata">

### Author: ![BlueGuyARed](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@BlueGuyARed](https://meta.discourse.org/u/BlueGuyARed)
#### Post date: [April 17, 2015, 11:27pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/8 "2015-04-17T23:27:49Z")

</div>

Also, by the way, we tried to change that users trust level back to zero… with no change. I might just go back and change all posts [200] to listed if there isn’t a fix.

---

<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: [April 17, 2015, 11:29pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/9 "2015-04-17T23:29:19Z")

</div>

Okay then, put this in a psql console:

```plaintext
discourse=# UPDATE posts
SET hidden = false, hidden_reason_id = NULL, hidden_at = NULL
WHERE user_id = (SELECT id FROM users WHERE username_lower = 'fhtzoob')
;

UPDATE 5000
discourse=# \q

```

Or, from a Rails console: (`./launcher enter app` then `rails c`)

```ruby
ActiveRecord::Base.exec_sql("UPDATE posts
SET hidden = false, hidden_reason_id = NULL, hidden_at = NULL
WHERE user_id = ?", User.find_by_username("fthzoob").id)

```

---

<div class="post-metadata">

### Author: ![NomNuggetNom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nomnuggetnom/32/122685_2.png) [@NomNuggetNom](https://meta.discourse.org/u/NomNuggetNom)
#### Post date: [April 17, 2015, 11:49pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/10 "2015-04-17T23:49:39Z")

</div>

Awesome! Thank you very much 😄

---

<div class="post-metadata">

### Author: ![FHTzoob](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fhtzoob/32/37485_2.png) [@FHTzoob](https://meta.discourse.org/u/FHTzoob)
#### Post date: [April 18, 2015, 7:19am UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/11 "2015-04-18T07:19:33Z")

</div>

Um… not all my posts came back…

---

<div class="post-metadata">

### Author: ![BlueGuyARed](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@BlueGuyARed](https://meta.discourse.org/u/BlueGuyARed)
#### Post date: [April 18, 2015, 4:58pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/12 "2015-04-18T16:58:37Z")

</div>

I think you’ll have to log in for the posts to update… which you can’t since your suspended.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [April 18, 2015, 7:16pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/13 "2015-04-18T19:16:20Z")

</div>

> [@BlueGuyARed](#):
>
> which you can’t since your suspended.

In that case wouldn’t the procedure be to 99999 Suspend instead of dropping Trust Level below the minimum?

---

<div class="post-metadata">

### Author: ![NomNuggetNom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nomnuggetnom/32/122685_2.png) [@NomNuggetNom](https://meta.discourse.org/u/NomNuggetNom)
#### Post date: [April 19, 2015, 1:55am UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/14 "2015-04-19T01:55:37Z")

</div>

Yup. That’s what we did. Another admin did it because he misunderstood what it did.

@riking How about unlisting topics? Here’s my guess:

```plaintext
ActiveRecord::Base.exec_sql("UPDATE topics
SET hidden = false, hidden_reason_id = NULL, hidden_at = NULL
WHERE user_id = ?", User.find_by_username("fthzoob").id)

```

---

<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: [April 19, 2015, 2:17am UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/15 "2015-04-19T02:17:39Z")

</div>

You want `visible = true`.

---

<div class="post-metadata">

### Author: ![NomNuggetNom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nomnuggetnom/32/122685_2.png) [@NomNuggetNom](https://meta.discourse.org/u/NomNuggetNom)
#### Post date: [April 19, 2015, 2:25am UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/16 "2015-04-19T02:25:24Z")

</div>

Hmm. It doesn’t like that.

```plaintext
PG::UndefinedColumn: ERROR: column "hidden_reason_id" of relation "topics" does not exist
LINE 2: SET visible = true, hidden_reason_id = NULL, hidden_at = NUL...
                            ^

```

Removed `hidden_reason_id`, then got this:

```plaintext
PG::UndefinedColumn: ERROR: column "hidden_at" of relation "topics" does not exist
LINE 2: SET visible = true, hidden_at = NULL
                            ^

```

Removed `hidden_at`, then got this:

```plaintext
PG::SyntaxError: ERROR: syntax error at or near "WHERE"
LINE 3: WHERE user_id = 8048
        ^

```

---

<div class="post-metadata">

### Author: ![Silvanus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/silvanus/32/62831_2.png) [@Silvanus](https://meta.discourse.org/u/Silvanus)
#### Post date: [September 6, 2016, 8:09am UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/17 "2016-09-06T08:09:19Z")

</div>

I had a similar problem. Used the following and it worked. First, entered `./launcher enter app` then `rails c` and then:

```
ActiveRecord::Base.exec_sql("UPDATE posts
SET hidden = false, hidden_reason_id = NULL, hidden_at = NULL
WHERE user_id = ?", User.find_by_username("USER_NAME_HERE").id)

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [March 3, 2019, 8:39am UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/18 "2019-03-03T08:39:21Z")

</div>



---

<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: [March 3, 2019, 10:01pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/19 "2019-03-03T22:01:32Z")

</div>

@codinghorror this does not happen too much, but I wonder if we should have some protection here for our “hiding” code, maybe if you have more than N (100) posts don’t ever do a batch hide?

---

<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: [March 3, 2019, 10:02pm UTC](https://meta.discourse.org/t/batch-unhide-posts/27716/20 "2019-03-03T22:02:11Z")

</div>

Yes that does sound like a good idea

[Next page](https://meta.discourse.org/t/batch-unhide-posts/27716.md?page=2)
