Create new SSO users without sending welcome emails

AI-generated summary

The discussion revolves around creating SSO users in Discourse without triggering welcome emails, particularly for importing historical posts. rcfox explains the need to avoid sending emails to users who haven’t actually visited the forum, noting an accidental email send to 300 test users. They inquire if users can be created via the API without using the /session/sso route, or if a parameter like active=true can suppress emails. riking notes that the email disable notice is intentional to prevent oversight, while DeanMarkTaylor suggests hiding it via CSS, though codinghorror supports the visibility for user expectations. dansingerman shares that they implemented this functionality via a pull request, which sam confirms was merged, advising users to update the wiki.

I need to create several user accounts in order to import historical posts, and my forum uses SSO. Fortunately, I can automatically login and impersonate the user on my site and then make the necessary request to login to Discourse with SSO. However, I don’t want to trigger the welcome email for these users since they haven’t actually visited the forum themselves. (I just accidentally sent emails to ~300 users on my test Discourse. D:)

I noticed that all emails can be disabled, which I could do temporarily. It’s a little weird that it advertises the fact that emails are disabled to all users though. It’d also be really nice if the email could be triggered when the user actually visits, but I could live without that.

So:

  1. Can users be created with SSO using the API, and not the /session/sso route?
  2. If not, is there something like active=true I can use for SSO?

Thanks!

That’s to avoid the issue where you forget that you disabled emails, and then launch the forum with that enabled :wink:

You could always hide this with CSS.

But be realistic how long will it really display… and will you forget to switch it off?

I think it makes sense to show to admins, but does it make sense to show it to all users?

It does, as users might expect to get notification emails, signup emails, etc.

I need this functionality as well (suppressing emails when SSOing a user) - so I have created a pull request here: Add an sso option to suppress welcome emails by dansingerman · Pull Request #3289 · discourse/discourse · GitHub

Merged in, be sure to update the wiki