Merge User Accounts

:notebook_with_decorative_cover: This is a how-to topic that will guide site admins through the process of merging multiple user accounts into a single Discourse account.

As of Discourse 2.5.0.beta3, site admins can merge non-staff users through the Discourse UI, and through the rails console for their site.

Merging user accounts in Discourse can be useful in several scenarios:

  • Sometimes a user may end up with more than one account, perhaps because they forgot they had registered before.
  • If a user changes their email address and creates a new account instead of updating their existing account, you might also want to merge the accounts to keep their history intact.
  • In some cases, a user might have different accounts for different roles (e.g., personal use, official use, testing), and later decide to consolidate them into a single account.

Let’s discuss two ways site admins can merge user accounts in Discourse.

Merging Non-Staff Users

Merging non-staff users can be done directly via the Discourse UI.

:warning: Once two users are merged, the action cannot be undone. The source user account is deleted after the merge.

To merge two non-staff users together, navigate to the user admin page of the source user you want to merge into the target user's account, and then scroll to the very bottom and select the Merge button:

image

In the following popup window, type in the username of the account you wish to merge the user into, and click the Transfer and Delete button to merge the users.

image

:person_tipping_hand: Merging large accounts with other large accounts can be quite expensive in database and server time. Depending on the amount of data associated with the source user, merging user accounts can sometimes take a while to process.

When merging user accounts in Discourse, the content of 45 tables gets merged, and all data associated with the source user is merged into the target user, including:

  • Posts and topics created by the user
  • Likes given and received by the user
  • Private messages sent and received by the user
  • User profile information, such as the about me section, timezone, location, etc.
  • User preferences and settings
  • User actions and activity, such as bookmarks, topic views, etc.
  • User badges and achievements
  • User’s trust level and group memberships

In the event of potential conflicts, such as different user preferences, the target user’s details will be kept.

If both users had an anonymous user associated with their account (from the allow anonymous posting feature), the one owned by the source user will be lost.

Additionally, incoming links that still reference the source user (e.g. https://talk.example.com/t/some-topic/17/3?u=source_username) won’t be associated with the target_user.

:discourse: An Important Note about Merging Users and SSO

Merging user accounts can potentially impact SSO depending on how the SSO system is implemented. If the SSO is based on the email address, there should be no issue as long as the email address of the target account is the one used in the SSO system. However, if the SSO system uses a unique user ID that is different from the Discourse user ID, then merging could potentially cause issues if the source account’s unique ID is not correctly mapped to the target account.

Merging Staff Users

:discourse: If your site is hosted with Discourse, please reach out to team@discourse.org if you need to merge staff users.

For security purposes, staff users will still need to be merged via the console.

From the rails console for your site, all types of users can be merged by executing:

rake users:merge['source_username','target_username']

:person_tipping_hand: Be sure to ensure there is no space before/after the comma

5 Likes