Creating Discourse accounts during user import

Hi, all. I’ve just launched a new WordPress website using the excellent WP Discourse plugin for SSO and discussion.

Everything is working smoothly, but I’ve had to import a lot of user accounts from the client’s previous website. These users haven’t all logged in to the new website yet, but the client has asked whether they can be added to the Discourse forum as users, before logging in for the first time and generating their account via the SSO process.

Is it possible to create these accounts on Discourse without having the users login to WordPress and go through the SSO process?

Is the situation that the users exist on the current site, but have never logged into the WordPress site? If so, I’m not sure why you need to create Discourse accounts for them before they have logged in. If you enable the wp-discourse ‘Create Discourse User on Login’ setting, accounts will be created for them when they first login to your site.

If you really need to do it, you can create Discourse users from WordPress users through the API. Here’s an example of how to do it:

Edit: for sites using SSO, the best way to add users to Discourse before they login is to use the sync_sso route: Sync DiscourseConnect user data with the sync_sso route.


Hi @simon, thanks for the speedy reply. It’s mainly for the forum digest emails that get sent out. My client wants the website users to receive these emails without first having to sign in and access the forum.

Thanks for the link to that function, I’ll give it a go.

1 Like