How to prevent emails other than admin confirmation when granting Admin/Moderator access?

We are using Discourse as a hidden service and manage users through APIs.

When granting Admin or Moderator access to a user, we would like only the admin_confirmation_message email to be generated. Currently, the promoted user also receives additional emails such as:

  • user_private_message (e.g., “Congratulations, you’ve been granted admin/moderator status”)
  • user_replied

Is there a setting or recommended approach to prevent these additional emails from being sent to the promoted user while still retaining the admin confirmation behavior?

Relevant settings:

  • disable_emails = non-staff
  • default_email_level = 2(never)
  • default_email_messages_level = 2 (never)

We have already reviewed the email and notification-related settings, and the configuration appears to be the same as another environment where only the admin_confirmation_message email is generated.

I think this might work with disable_emails set to yes rather than non-staff, there are some emails that bypass this and admin_confirmation_message is one of them

It worked! The emails are only being sent for admin_confirmation_message now. However, I also need to include the forgot password email so that admins can reset their passwords if needed.

Because I am using a dockerized version of Discourse, I can’t directly modify the source code file you mentioned.

Is there another way to allow the “forgot password” email—or other email types—to bypass this restriction? Currently, I need to allow admin_confirmation_message, forgot_password, and test_message. If there is a way to add these, I can use that same method to add others in the future as well.