# Locking a post in the console

**URL:** <https://meta.discourse.org/t/locking-a-post-in-the-console/106410>\
**Category:** Development\
**Created:** [January 13, 2019, 11:15am UTC](https://meta.discourse.org/t/locking-a-post-in-the-console/106410 "2019-01-13T11:15:14Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![fhe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fhe/32/113345_2.png) [@fhe](https://meta.discourse.org/u/fhe)\
**Post date:** [January 13, 2019, 11:36am UTC](https://meta.discourse.org/t/locking-a-post-in-the-console/106410/5 "2019-01-13T11:36:58Z")

</div>

> [@csmu](#):
>
> I’m looking how to lock a post at this stage.

Yes, I’ve just realized that and edited my post accordingly.

> [@csmu](#):
>
> Can a logged staff action be created in the console?

I think utilizing the `PostLocker` from the console would be good, it also creates the staff log action.

```plaintext
Post.where(id: <pid>).find_each do |post| 
  locker = PostLocker.new(post, Discourse.system_user)
  locker.lock
end
```

---

_[View the full topic](https://meta.discourse.org/t/locking-a-post-in-the-console/106410)._
