How to disable mail for staged users?

Continuing the discussion from Description of various user states in Discourse (Admin / Moderator / Staff / Developer / Other ):

I’ve got a forum that includes a Google Groups import. For Reasons, the intention is that this will be a static archive of the Google Group. The Google Group will continue to function standalone and the forum will simply include its posts as static archived data. Right now, I’m doing that by periodically running the Google Import script, but think that I’ll soon instead configure incoming mail and subscribe the category to the Google Group list.

I have turned off enabled staged users. The users all show as active=false and staged=true.

If someone replies to a post, they get an email.

If someone PMs them, they get an email.

If I change the user’s staged status to false, they no longer get PMs, but they do still get notifications about replies to their messages. This seems like a fine behavior, and exactly what someone else was asking about just today, but this entity believes that they do not have permission to email these Google Groups users who have not created an account on the forum.

Maybe I can modify the import script and/or make a plugin that will do something like make all active=false users automatically set to staged=false? Maybe I set the archive category so that it cannot be watched (in a plugin, I guess)?

For the record, here’s how staged users are supposed to be treated:

2 Likes

Continuing the discussion from How to disable mail for staged users?:

Well, I didn’t figure out a way to keep staged users from getting email, so I guess I’ll do

def no_mail_for_staged_users
  staged=User.where(staged: true)
  staged.all.each do |user|
    o=UserOption.find_by(user_id: user.id)
    o.email_level = 2
    o.email_messages_level = 2
    o.email_digests = false
    o.save
  end
end

and modify the mbox script to similarly disable email for the staged users that it creates.

If anyone has any better ideas, I’d be interested to hear.

Are you on latest? There was a bug around staged users getting email that we fixed in the last week or two.

2 Likes

That would be good. I’ll check on Monday and see about undoing the user option changes.

1 Like

is there a plugin for this?

This is a very old topic and the thing that I was doing when I wrote this is no longer possible.

It looks like I added that function to the script that was importing the users. If that’s something that you want to happen for some reason, then you likely need a plugin to do it. Describe what’s happening that’s creating the staged users that you don’t want to receive email; you’ll likely need to update whatever it is that’s doing that to run a script like the one I included. If you need a custom plugin to do that, you can post in Marketplace or contact me directly.