Two-way Sync Between WP Discourse Username and Discourse Username?

I’ve moved this to the #support:wordpress category, because the #feature category is intended for Discourse features.

The Discourse Username Editable field in the WordPress plugin may be poorly named. The setting’s copy definitely needs to be updated to make it clear what the setting is intended for. When the Discourse Username Editable setting is enabled, users on the WordPress site can set their Discourse Username on their WordPress profile page. If that setting is not enabled, only an admin on the WordPress site can set the user’s Discourse username. The Discourse username is only used by the plugin for publishing posts from WordPress to Discourse.

When DiscourseConnect is used between WordPress and Discourse, the user’s Discourse username is initially set from their WordPress username. If the auth_overrides_username setting is enabled on the Discourse site, the username on Discourse can only be set from WordPress. If the auth overrides username setting is not enabled on Discourse, users could edit their username on Discourse so the usernames could be out of sync between the two systems.

In terms of the Discourse Username field, ideally, this field would always be set in the background based on the Discourse username. It’s a while since I last looked at the related code, but I believe the Discourse Username field is automatically filled in if the WordPress site is used as the SSO provider for Discourse and the “Create or Sync Discourse Users on Login” option is enabled on the DiscourseConnect Provider options tab on WordPress. The Discourse Username field is also automatically set if Discourse is used as the SSO provider for WordPress (with the DiscourseConnect Client setting.)

Ideally, the Discourse Username field would always be automatically set when WordPress is the SSO provider for Discourse, whether or not the “Create or Sync Discourse Users on Login” option is enabled on Discourse. I don’t think anything can be done for the case where DiscourseConnect isn’t being used between the two sites, but @angus might have ideas about that.

By default, WordPress does not allow users to change their usernames, so this isn’t something we’ve had a lot of questions about. If you want to ensure that usernames are kept in sync between WordPress and Discourse, make sure to enable the auth_overrides_username setting on Discourse. You might also want to enable the “Create or Sync Discourse Users on Login” option on WordPress. With that option enabled, users will be updated on Discourse each time they login to your WordPress site. If that option is not enabled, users will only be updated on Discourse when they log out of Discourse, then log back in with DiscourseConnect.

3 Likes