Wordpress account completely deleted when username is changed in Discourse (SSO with WP as Provider)

Continuing the discussion from SSO with Wordpress but users cannot change their username:

I’m using the Discourse Wordpress plugin with WP as my SSO provider.

When a person creates their account in WP, I have it set up that they create the account through Woocommerce. I also have a setting in place that prevents them from logging in until they have confirmed their WP account via email verification.

When a user then visits the forums, they have to click the “Login” button, and if the user has verified and is logged in, then they will be authenticated to Discourse and their forum account provisioned.

I have been allowing users to change their username in Discourse

What are the consequences of changing a user username?

Well, I’ve noticed that what happens in Wordpress is that their account is REMOVED/DELETED from my Woocommerce/WP database. Nowhere to be found.

Then when the user tries to log back in, they can’t… of course, b/c they don’t have an account on WP anymore. Is this expected? Has anyone else experienced this?!

I’ve since changed the “username change period” to “0”

“The maximum number of days after registration that accounts can change their username (0 to disallow username change).”

If someone wants to change their username they can contact us and we can change it in Wordpress so that it matches in the forums. That seems to work. (using the “Username Changer” plugin that @AdamCapriola suggested here.)

The only changes that the WP Discourse plugin makes to a WordPress user when WordPress is the SSO provider for Discourse is to add discourse_sso_user_id and discourse_username meta-data fields to the user. The plugin does not do anything that I know of that would cause a WordPress user to be deleted from the database when they change their username on Discourse.

The only consequence of a user changing their username on Discourse that I know of is that the user’s Discourse Username that is stored on WordPress could get out of sync with the user’s actual Discourse username. If this happened, it would affect the user’s ability to publish posts to Discourse. It should not cause any problems with SSO login. It should definitely not cause the user to be deleted from the WordPress database.

This is a WordPress issue, not a Discourse one, but I would not recommend using a plugin to override basic WordPress functionality. Usernames are not intended to be editable on WordPress. It would be best to stick with that default behaviour.

4 Likes