# Rake task for merging users

**URL:** https://meta.discourse.org/t/rake-task-for-merging-users/89086
**Category:** Announcements
**Tags:** new-feature, merge-user
**Created:** [March 1, 2018, 12:56pm UTC](https://meta.discourse.org/t/rake-task-for-merging-users/89086 "2018-03-01T12:56:29Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 1, 2018, 12:56pm UTC](https://meta.discourse.org/t/rake-task-for-merging-users/89086/1 "2018-03-01T12:56:29Z")

</div>

As of [Discourse 2.5.0.beta3](https://meta.discourse.org/t/discourse-2-5-0-beta3-release-notes/148766), site admins can merge non-staff users without needing to access the console. For security, staff users will still need to be merged via the console.

Visit the user admin page, and select “Merge” at the bottom of the page.  
 ![image](https://global.discourse-cdn.com/meta/original/4X/9/a/9/9a947b005ca785b088b8fd25443dace417dc0cd7.png)

Enter the username you want the account to be merged into, and click “Transfer & Delete @username” to start the merge process.

 ![image](https://global.discourse-cdn.com/meta/original/3X/f/1/f1b05468b020ced2b1577614bbf0510d34f64a6c.png)

* * *

The rake task for merging users is now available on `tests-passed`. ☀

[https://github.com/discourse/discourse/commit/7a2183e8ab97c26464da541014ba1f2e69669a82](https://github.com/discourse/discourse/commit/7a2183e8ab97c26464da541014ba1f2e69669a82)

Users can be merged by executing

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

```

(note: ensure there is no space before/after the comma)

This merges the data of the `source user` into the `target user` before it **deletes** the `source user`. The content of 45 tables gets merged, so depending on the amount of data associated with the `source user` this process can take a while.

**Plugin authors** can hook into the merge process by handling the `:merging_users` event. I’ve already implemented it for the polls plugin, which merges the votes of the two merged users.

**Known problems:**

1. 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`.

2. A user can have only one shadow user (from the `allow anonymous posting` feature). So, if both merged users had a shadow user, then the one owned by the `source user` will be lost… well, it’s still there, but not associated with an existing user anymore.

---

_[View the full topic](https://meta.discourse.org/t/rake-task-for-merging-users/89086)._
