# Reset default categories watching setting

**URL:** <https://meta.discourse.org/t/reset-default-categories-watching-setting/244930>\
**Category:** Product Support\
**Created:** [November 8, 2022, 10:15pm UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930 "2022-11-08T22:15:21Z")\
**Posts on this page:** 7\
**Page:** 1

## AI-generated summary

Users [ufukayyildiz](/t/-/244930/1) and [mononym](/t/-/244930/3) are struggling to reset the "default categories watching" setting for all users on their Discourse site, as user preferences persist despite site-wide changes. [Arkshine](/t/-/244930/5) explains this is intentional — user choices override defaults — and suggests educating users instead. [mononym](/t/-/244930/6) explains their site restructured announcements from many topics to a few, requiring users to be notified via watched categories, but existing preferences block this. They seek a way to reset or copy preferences, ideally via Rails console. [mononym](/t/-/244930/7) shares a suggested Rails command to update email preferences, but later confirms a multi-step fix [mononym](/t/-/244930/8): 1) Set category 31 to watched by default in site settings; 2) Reset all users’ `email_level` to 1 via `UserOption.update_all(email_level: 1)`; 3) Delete per-topic notification preferences with `TopicUser.where(topic_id: <topic_id_nr>).destroy_all`; 4) Manually create missing category preferences for users with no entry via a loop creating `CategoryUser` records with `notification_level: 3`. These steps successfully restore expected notification behavior, though caution is advised as they alter user data.

<div class="post-metadata">

**Author:** ![ufukayyildiz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ufukayyildiz/32/217157_2.png) [@ufukayyildiz](https://meta.discourse.org/u/ufukayyildiz)\
**Post date:** [November 8, 2022, 10:15pm UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930/1 "2022-11-08T22:15:21Z")

</div>

hi,

i am trying to reset `default categories watching` for all users but no success.

Although seems no categories selected in setting area users preferences have some categories selected.

## ![image](https://global.discourse-cdn.com/meta/original/4X/7/5/b/75b80c91a668d515bd8f6c506ebccf49afa7e3c9.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/5/9/d59b88f29fc200fd7de3ab4559fc30ddc965056d.png)

---

<div class="post-metadata">

**Author:** ![mononym](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mononym/32/566879_2.png) [@mononym](https://meta.discourse.org/u/mononym)\
**Post date:** [January 8, 2025, 6:58pm UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930/3 "2025-01-08T18:58:17Z")

</div>

Hello @ufukayyildiz

Did you find out how to proceed with this issue ? While doing the same I had some trouble as well. It ended up not working at all ^^ c.f. [Members not receiving emails from Watched category (again)](https://meta.discourse.org/t/members-not-receiving-emails-from-watched-category-again/346093)

---

<div class="post-metadata">

**Author:** ![ufukayyildiz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ufukayyildiz/32/217157_2.png) [@ufukayyildiz](https://meta.discourse.org/u/ufukayyildiz)\
**Post date:** [January 31, 2025, 12:37am UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930/4 "2025-01-31T00:37:15Z")

</div>

No, Not yet.

---

<div class="post-metadata">

**Author:** ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)\
**Post date:** [January 31, 2025, 1:09am UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930/5 "2025-01-31T01:09:31Z")

</div>

I believe it’s designed so that the setting respects the user’s choices. So, if a user manually adds a category, it won’t be overwritten.

You might be able to do some magic from the Rails console, but I think a better approach would be to educate your users. What do you think? Or do you have a specific situation in which you are required to change the default no matter what?

---

<div class="post-metadata">

**Author:** ![mononym](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mononym/32/566879_2.png) [@mononym](https://meta.discourse.org/u/mononym)\
**Post date:** [February 1, 2025, 10:29am UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930/6 "2025-02-01T10:29:26Z")

</div>

Thanks for your reply.

I would be very happy about a rails console command to copy user preferences. I absolutely understand the design choice that user preferences prime over site settings. But the problem is that sites are evolving and their organization with it.

In our case, we switched from an organization where all announcements are posted as a new topic: the result was a huge amount of undiscussed topics (1 post only) on the front-page. I now see that I started looking into that case in Feb 2023 [Unlist or archive a post when it has no reply per category](https://meta.discourse.org/t/unlist-or-archive-a-post-when-it-has-no-reply-per-category/256176).

As these announcements are relevant and containing deadlines, it was not a choice to hide them from the front-page. So we moved to an organization with 5 dedicated topics (type of announcement) in which each post is a new announcement.\[1\] Still as these posts are important, we tried to set the category to watched in order to get users notified in real time.

This was the beginning of the situation which resulted currently in nobody getting anything except _user\_mentioned_ and _digest_. The switch would have been so much easier if one could just reset all user preferences to the new site defaults. Or, as another idea, copy the user preferences of a _virtual_ new signup to all other users.\[2\]

Meanwhile, I told the users about the fact that systems sometimes don’t work as intended and that notification emails won’t come for an undefined period of time.

* * *

1. Here it would be very useful to be able to enable “Reply to Topic” only. 

2. Which I can image is currently possible via rails.

---

<div class="post-metadata">

**Author:** ![mononym](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mononym/32/566879_2.png) [@mononym](https://meta.discourse.org/u/mononym)\
**Post date:** [March 31, 2025, 2:06pm UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930/7 "2025-03-31T14:06:35Z")

</div>

Hello again. I am still looking into this and in our case resetting the user preferences makes sense because the structure of the site has changed which has led to a change in the way email notifications work.

From the discourse AI, I got suggested the following rails command:

```ruby
UserOption.update_all(email_digests: true, email_level: 1, email_messages_level: 1)

```

Do you think this would achieve what we’re looking for ?  
Thanks !

---

<div class="post-metadata">

**Author:** ![mononym](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mononym/32/566879_2.png) [@mononym](https://meta.discourse.org/u/mononym)\
**Post date:** [April 1, 2025, 8:37am UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930/8 "2025-04-01T08:37:21Z")

</div>

I think the bellow steps solved the issue !

In the site settings I set the category (31) to be watched by default, retroactively.  
Check:

```ruby
CategoryUser.where(category_id: 31).pluck(:user_id, :notification_level)

```

Most users have a `notification_level` of `3` for my category `31`. 👍

Now there are two things in the way for this change to have a 100% effect:

1. The user’s global email preferences.
2. The user’s notification preferences for each topic in the category (31).

* * *

⚠ The following lines will modify personal settings of your users. Don’t get into a fight.

First, in order to “reactivate” the user’s emails, one has to set the users `email_level` to 1 (i.e. “when away”) or 2 (“always”):

```ruby
UserOption.update_all(email_level: 1)

```

Check:

```ruby
UserOption.group(:email_level).count

```

I get something like `=> {1=>X}` with `X` being the number of users.

Second, the topic `notification_level` has priority over the category `notification_level` (which was modified in the site settings). The easiest way is to get the topic preferences out of the way. To do so, one simply deletes the entries topic by topic:

```ruby
TopicUser.where(topic_id: <topic_id_nr>).destroy_all

```

Check:

```ruby
TopicUser.where(topic_id: <topic_id_nr>).exists?

```

Getting something like `=> []` which means no user has topic preferences and the category `notification_level` will be the default for all users.

* * *

N.B.: Somehow, some users still had no notification preferences for the category (31) set (i.e. no entry in the `category_user` table). To make sure their `notification_level` is set, one has to create an entry with the value for `notification_level`:

```ruby
User.find_each do |user|
  unless CategoryUser.exists?(user_id: user.id, category_id: 31)
    CategoryUser.create!(user_id: user.id, category_id: 31, notification_level: 3)
  end
end

```

Check:

```ruby
CategoryUser.where(category_id: 31).pluck(:id, :notification_level)

```
