Create user automatically in Discourse when they sign up in Wordpress?

this is an awesome idea

The option to create a new user wasn’t working for me so I dug into the plugin code and figured out why. In case this is helpful to anyone else:

The create_discourse_user function runs as a result of WP’s wp_login action but for some reason, wp_login doesn’t get fired in my setup of WP when someone creates an account.

It’s probably because we use the WP plugin MemberMouse to handle members and it hijacks the registration/login system in unexpected ways.

So I added in a new way of firing off create_discourse_user and it works now.

7 Likes

any instructions on implementing this?

It can be done with the WP Discourse plugin. You need to be using WordPress as the SSO provider for Discourse and also select the SSO Provider option Create or Sync Discourse Users on Login.

There are cases where this doesn’t work due to conflicts with other plugins. If you run into a problem with it, let us know and we’ll try to work it out.

The code that I posted in this topic is no longer necessary.

2 Likes

Hello,

I activated the WordPress as the SSO provider for Discourse and also select the SSO Provider option Create or Sync Discourse Users on Login

But after a login with a new user, this user doesn’t appear in discourse’s back office.

Do you have an idea for solve that ?

Thanks for your help
Eric

Is SSO working correctly for you when a user clicks the Login button on Discourse?

Yes the SSO is working fine, I can connect to discourse and the user is created at this moment.
But For my project I need to create the user after account creation in wordpress because for some users I want to change the level of them after a subscription in wordpress.

Thanks for your help

This should work. Sometimes there is a conflict with another plugin. What are the main plugins on your site?

I have this plugins:

I find the problem the publishing username of my api has a space and special characters, after i Changed it on the configuration, the transmission is ok:

Thanks :wink:

1 Like

Great! Yes, that makes sense. SSO works without the API key, but the sync_user function requires the API key and Publishing Username.

1 Like