Ability to merge users

(cpradio) #46

That has been my experience as well

(Joshua Rosenfeld) #47

That would be Stonehearth’s case as well. We don’t get a lot of email, but every so often will find someone with two accounts - usually due to a work and personal email.

(Dave McClure) #48

We just did an import from another system and some existing users had a different alias there. I think there are only a small number of users that I would like to merge, but this would be helpful.

In the mean time, I’m looking for the recommended workaround… I am sure it’s around here somewhere in this topic or one of the ones it links to/from, but I’m not finding it at the moment. Can someone point me to it, please?

(Andrew Waugh) #49

How much was included in your import? If you only imported user posts, then it is relatively straightforward in the CLI. In the GUI you can open the “origin” user’s profile, select their posts (and PMs) one by one, then select their posts in the topic, then reassign ownership, but this gets old pretty quickly.

If your import contains @mentions, or the source user’s email then it gets a bit more complicated.

(Dave McClure) #50

Just users, topics and posts were imported.

I think this would be sufficient for my current needs. Are the CLI commands to do this in some post around here?

They do, but I’m fine leaving that stuff alone wherever it exists.

(Andrew Waugh) #51

Here is my cheatsheet:

Our migration left us with a number of what I refer to as “Splithead Users”. By that I mean members who have used various usernames and emails at various times, both before the migration and also after (many misunderstood our reactivation instructions and created a new account). The end result is the same: a forum member has a few “ghost” identities spread across the content.

I have created a test discourse installation to work on methods of rejoining all these identities back to a single account, here is how I go about this at the moment:

Migrating a splithead user:


Target_Username: User who will end up as the active account.
Historical_Username: A former username
Historical_Email: A former user email

./launcher enter app

  1. Change the ownership of the posts
    rake --trace users:change_post_ownership[Historical_Username,Target_Username]
    rake --trace users:change_post_ownership[Historical_Username,Target_Username,private]
  2. Convert any occurances of Historical_Email to mentions
    rake --trace posts:remap[“Historical_email”,"@Target_Username"]
  3. Change old content like “from:” and "in reply to:"
    rake --trace posts:remap["Historical_Username ","Target_Username "]
  4. Rebake the posts
    rake --trace posts:rebake_match[“Target_Username”]

Notes & Caveats:

You have to be careful with step 3) above, if you have a historical username “Waterloo” then this will mess up any post with text like “The Battle of Waterloo”, “Waterloo Station”, or “My favourite ABBA song is Waterloo”, so think about this carefully.

2 & 3 above may not be necessary if your import doesn’t contain that sort of content.

The above procedure will probably mess up your user statistics table.

None of this is reversible.

Update quotes and mentions when username is changed
Update quotes and mentions when username is changed
(Robert Hudson) #52

Is it possible to do this in bulk?

(Sam Saffron) #53

Sorry, no, not at the moment, there is no “bulk” option for change user ownership.

(Robert Hudson) #54

No worries, thanks. This would be a handy feature…

(Elizabeth Wyatt) #55

A bulk merge feature would be very useful for us too. Many of our users change departments and therefore change email address, it would be great if there was some way to either avoid using their email address as their UID or be able to merge users when a new one is created.

(Jeff Atwood) #56

I think an alternative solution is superior; we are adding multiple email addresses per user per @LeoMcA and @tgxworld.

However only one email can be associated with one user at a time though. Email = identity, which means the same email can’t be associated with 2,3,4, or 100 users. Like highlander, there can be only one!

(Barry van Oudtshoorn) #57

Hmm, I’m not sure that this would alleviate the issue in an SSO context, though, as by that stage the new user would have already been created, and started performing actions. I guess if they pick up on this and alert a mod/admin, that person could delete the new user, update the old one, and then have them SSO back in, but that seems cumbersome. :confused:

This being the case, I would suggest that having multiple email addresses is, in many cases, orthogonal to the issue of merging accounts (although not all cases, and I can see how a merge could be predicated on the availability of multiple email addresses if only to avoid having to choose the “right” one). In other words, multiple email addresses would be wonderful, but the ability to merge users would be spectacular. (Especially for those without access to the CLI…)

(Jeff Atwood) #58

How is it different?


  • account x at jane@example.com
  • account y at pam@example.com

You can…

  • add new email to account X: jane@example.com, jane.doe@example.com
  • remove original email from account X: jane.doe@example.com
  • this email is now unusued!
  • add that email to account Y: pam@example.com, jane@example.com
  • remove original email from account Y: jane@example.com

Now you have

  • account x at jane.doe@example.com
  • account y at jane@example.com

and have effectivelly transferred account Y to that person.

(Barry van Oudtshoorn) #59

I guess my point is that that’s quite a complicated and complex process.

It still doesn’t help administrators to combine accounts where actions have been performed by both – likes, posts, votes, etc.; this would remain an additional step, and would, if I understand correctly, have to be done from the CLI.

There’s also the issue of transferring sessions from one account to another; otherwise, especially in an SSO context, someone could remain logged into account X and perform additional actions. Merging could get around this by disallowing merging where more than one account has an active session, and only allowing you to merge into the account with most recent activity. Yes, you could do this with email transfer, but this would be prone to human error and is non-atomic. :slight_smile:

The actual workflow for merging once multiple email addresses would, in my understanding, be:


  • Account X at jane@example.com
  • Account Y at pam@example.com

You would need to

  • Determine that account Y should be the target of the merge by looking at activity
  • Disable account X, invalidating any active sessions
  • Transfer ownership of all posts, likes, votes, bookmarks, badges, etc. from X to Y, intelligently discarding duplicates so that account Y doesn’t end up with two “First like” badges (or similar) – or contact the Discourse team to do this for you if they’re your host :wink: .
  • Change the email on account X to jane+random@example.com
  • Add jane@example.com to account Y
  • (Optionally) remove pam@example.com from account Y

…and then you would have merged accounts X and Y.

(Jeff Atwood) #60

Yeah true this is more like transferring accounts not so much merging them, still for now you can edit each post and transfer ownership as needed so there is a workaround.

(Leo McArdle) #61

Since this has a #pr-welcome tag on it, In case anyone is interested in contributing this feature, you can take my:

and revise that to:

I’m not interested in submitting a PR for this.

Only a handful of our users on the Mozilla Discourse have multiple accounts, and would benefit from this feature, so it’s a better investment of our time to push multiple email addresses per user to completion and then manually clean up the remaining accounts.

That being said, we would still be happy to see this feature (and benefit from it in those few cases), so if you’re reading this and thinking about taking a crack at it, go for it, good luck, and feel free to reach out to me if want any help getting started! :smile:

(Robert Hudson) #63

As i noted above, we would certainly benefit from being able to have multiple email addresses per user - we don’t need Discourse to deliver email notifications to more than one user (thus there would be a primary address which would receive email updates, and then multiple secondaries, which could potentially be used to tie inbound emails from more than one source email address to a given account).

A process to then clean up/merge old accounts into the primary account would then be awesome. I’d happily do that manually as a one-off if that’s what’s required.



(Thomas Purchas) #65

@AndyatFocallocal you can use the Watching/Tracking/None button on each topic and category to select a notification level.

You don’t need to create a post to receive a notification.

Here are a couple of screenshots highlighting the buttons, they are not alway obvious :slight_smile:

(Barry van Oudtshoorn) #66

I just had to “transfer” an account today, but ran into an issue: when I went to change the user’s email address, I wasn’t able to do so, as it requires validation of that address (according to the settings in use). I wonder if this check should be waived when it’s an admin updating the email address? Otherwise, this process becomes a smidge more complex. :wink:

(Andrew Waugh) #67

You can get around that: