# Edit a user preference for everyone or a subset of users

**URL:** https://meta.discourse.org/t/edit-a-user-preference-for-everyone-or-a-subset-of-users/25162
**Category:** Self-Hosting
**Tags:** how-to
**Created:** [February 12, 2015, 3:03pm UTC](https://meta.discourse.org/t/edit-a-user-preference-for-everyone-or-a-subset-of-users/25162 "2015-02-12T15:03:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [February 12, 2015, 3:03pm UTC](https://meta.discourse.org/t/edit-a-user-preference-for-everyone-or-a-subset-of-users/25162/1 "2015-02-12T15:03:23Z")

</div>

> :bookmark: This guide explains how to edit a user preference for everyone or a subset of users in Discourse.
> 
> :person_raising_hand: Required user level: System Administrator
> 
> :warning: Console access is required.

If you need to update the user preference for all of your users or a large subset of users, you can do so via the rails console.

## Summary

In this guide, you’ll learn:

- How to access the Rails console for making bulk changes
- Examples of modifying user preferences
- How to identify settings names

## Accessing the Rails console

To enter the Rails console in your Discourse setup, execute the following commands:

```plaintext
./launcher enter app
rails c

```

Then, run a command that selects the set of users you wish to update.

## Examples of modifying user preferences

Below are command examples to update various user preferences:

### Setting the last seen date for inactive users

Set the last seen date for users who have never logged in.

```ruby
User.where("last_seen_at IS NULL").update_all(last_seen_at: 1.week.ago)

```

### Disabling mailing list mode for all users

Switch users back to the default to prevent them from receiving emails for every new post.

```ruby
UserOption.update_all(mailing_list_mode: false)

```

### Setting email level to only when away for all users

Revert to default settings to prevent email notifications when users are actively present on the site.

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

```

_Where `email_level` can have values:_

- _0: always (send emails even when user is active)_
- _1: only when away (default)_
- _2: never_

### Enabling chat for all beta group members

```ruby
beta_group = Group.find_by(name: "beta")
beta_group.users.each do |user|
  UserOption.where(user_id: user.id).update_all(chat_enabled: true)
end

```

### Configuring email notifications to exclude previous replies

Set preference to exclude previous replies in email notifications.

```ruby
UserOption.update_all(email_previous_replies: 0)

```

_Where `email_previous_replies` can have values:_

- _0: always_
- _1: unless previously emailed_
- _2: never_

For more information, refer to [controlling previous replies in emails](https://meta.discourse.org/t/how-to-control-previous-replies-in-emails/39834).

## Identifying the name of a setting

To determine the user setting name and available options:

- Use the [data explorer plugin](https://meta.discourse.org/t/data-explorer-plugin/32566) to inspect the `user_options` table.
- Search the Discourse GitHub repository.

For example, to adjust the setting related to “When I post in a topic, set that topic to,” you need to modify the `notification_level_when_replying` user option.

Check the [relevant setting](https://github.com/discourse/discourse/blob/main/app/models/user_option.rb) to [watching](https://github.com/discourse/discourse/blob/main/lib/notification_levels.rb).

You can also configure Docker to expose `psql` and utilize PGadmin for easier management.

> Last edited by @dax 2026-07-14T11:26:24Z
> 
> > **Check document**
> >
> > Perform check on document:
