# 如何删除论坛上的所有内容，只保留用户？

**URL:** https://meta.discourse.org/t/how-to-delete-everything-from-my-forum-and-just-leave-the-users/248083
**Category:** Support
**Created:** [2022年十二月7日 02:25 UTC](https://meta.discourse.org/t/how-to-delete-everything-from-my-forum-and-just-leave-the-users/248083 "2022-12-07T02:25:27Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2022年十二月7日 23:33 UTC](https://meta.discourse.org/t/how-to-delete-everything-from-my-forum-and-just-leave-the-users/248083/12 "2022-12-07T23:33:22Z")

</div>

您有多少用户？  
如果您必须从头开始，另一种选择是导出用户的电子邮件地址（例如，使用数据浏览器），将其另存为 CSV 文件，重新创建您的论坛，然后使用 CSV 文件批量邀请您的用户。

* * *

另一个想法，比较困难，而且我不确定它是否能按我设想的那样工作。  
使用 data-explorer 导出您想保留的所有用户数据（既然您不想保留他们的头像，也许您也想跳过其他信息）并将结果导出为文件。  
然后，在安装新论坛后，创建一个 rails 脚本来解析文件并在数据库中创建用户条目（以及他们的选项、电子邮件等）：🤷

这是在 rails 控制台中创建用户的示例：

> [@How to manually add users and email in console mode?](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/9?u=canapin):
>
> I do have a question about email notifications using this method. I have added users through the console using the following commands: u = User.create!(username: ‘xx’, email: ‘xx@xx.com’, password: ‘xxx’, mailing\_list\_mode: ‘true’);u.approve(Discourse.system\_user, false) ; u.activate I have enabled “Send all new users a welcome message with a quick start guide” in [http://forum.brickfield.org.uk/admin/site\_settings/category/uncategorized](http://forum.brickfield.org.uk/admin/site_settings/category/uncategorized) However, emails are not being sent to users being add…

我在[https://meta.discourse.org/t/import-users-from-csv/79203找到的另一个脚本：](https://meta.discourse.org/t/import-users-from-csv/79203%E6%89%BE%E5%88%B0%E7%9A%84%E5%8F%A6%E4%B8%80%E4%B8%AA%E8%84%9A%E6%9C%AC%EF%BC%9A)

> <https://gist.github.com/michaeltcoelho/6616f3b707692fb4eedaa75d85c299d3>

该脚本在某个时候不起作用（因此是 #Support 类别 😄），但它仍然可能包含有趣的信息。

---

_[View the full topic](https://meta.discourse.org/t/how-to-delete-everything-from-my-forum-and-just-leave-the-users/248083)._
