Merge user accounts

Reports ::: report_mergeusers
Maintained by Nicolas Dunand
This script will merge two Moodle user accounts, "user A" and "user B". The intent of the script is to assign all activity & records from user A to user B. This will give the effect of user B seeming to have done everything both users have ever done in Moodle.
Latest release:
35 sites
8 fans
Current versions available: 1

All administrators who installed this plugin are kindly invited to replace it by this:, since the report_mergeusers plugin is no longer maintained.

In addition, there is a lot of new functionality (CLI scripts, merging reports stored in database, etc See the included README.txt for more details).


Nicolas Dunand (Lead maintainer): author
Mike Holzer
Mike Holzer: author
Forrest Gaston: author
Jordi Pujol-Ahulló: author
RISET Université de Lausanne: Supporting institution
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Wed, Aug 14, 2013, 8:50 AM
    Hey Team!

    Thank you for making this plugin. I think this is a fantastic idea! I was able to get the plugin installed, but I'm not able to get it operate. When I try to operate the plugin on my dev site I'm getting the following error:

    Merging «mergedaccount2» (user ID = 6) into «mergedaccount1» (user ID = 5)
    Unsupported database type

    Debug info:
    Error code: errordatabase
    Stack trace:
    line 476 of /lib/setuplib.php: moodle_exception thrown
    line 126 of /report/mergeusers/index.php: call to print_error()

    Here is some information about by dev site:
    Moodle -- 2.5 (Build: 20130514)
    MySQL -- 5.5.30
    PHP -- 5.4.15

    Do you know why this error might be occurring? I've attempted to debug, but there isnt' much to work with. Any insight would be great appreciated. Thank you!!



  • Wed, Aug 14, 2013, 7:41 PM
    Hi Steve,
    Thanks for your feedback. This comes from a typo in the code: on line 117 of /report/mergeusers/index.php , "mysql" should be "mysqli". You can correct this file yourself if you're in a hurry, and I'll update the code in GitHub and here ASAP.
  • Wed, Aug 14, 2013, 11:30 PM
    Nicholas --

    Thanks for your reply and insight. I and made the modification and tested it, but it didn't work. I decided to do a find an replace on all "mysql" for "mysqli". Once I replaced all the instances of "mysql" it worked. It needs to be updated on:

    Line 117
    Line 147
    Line 171
    Line 210

    I hope this helps. Thanks! Cheers!

  • Wed, Aug 14, 2013, 11:40 PM
    Nicholas --

    After getting the modification in place for "mysql" to "mysqli" as mentioned in the prior post, I'm getting an error when I look at the merged profile. Here is what I'm seeing:

    Error: mdb->get_record() found more than one record!
    line 1409 of /lib/dml/moodle_database.php: call to debugging()
    line 1369 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
    line 1348 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
    line 269 of /user/profile/lib.php: call to moodle_database->get_record()
    line 36 of /user/profile/lib.php: call to profile_field_base->load_data()
    line 357 of /user/profile/lib.php: call to profile_field_base->profile_field_base()
    line 106 of /user/editadvanced.php: call to profile_load_data()

    It looks like it is creating a duplicate record instead of updating the prior record. Do you have any insight on why that might be occurring? Please let me know if I can provide any additional information. THANK YOU! Cheers.

  • Thu, Aug 15, 2013, 4:43 AM
    I have duplicate users due to trying to match usernames and passwords with powerschool so that students don't have to remember two diff username and password sets. The problem is, when a user logs in with their new login and password, they want to edit their profile to change email address but get an error indicating that the email address is already in use (by their older account). Will this tool help me in any way?
  • Fri, Oct 11, 2013, 7:58 PM
    Hi all,

    My name is Jordi from the Universitat Rovira i Virgili of Tarragona, Catalonia, Spain.

    We use Moodle in our university and, by now, have lots of cases of duplicated users. Most of them by changes on the personal identifiers of Moodle users, synced from ldap.

    We have forked your plugin in github and expect to work on it on common Moodle things in short.

    We created a similar script on M1.9 and maintained by only us. We join efforts working on this plugin, hoping more feedback and having a great mergin tool that I can see is a headache by most of administrators.

    Thanks a we'll be back soon.

  • Wed, Oct 16, 2013, 5:19 PM
    Hi Jordi,

    Thanks for providing feedback, I'm looking forward to seeing what you have in mind smile
  • Mon, Dec 9, 2013, 10:48 PM
    Hi all,

    You can find newer versions of this plugin on the github repository, with several improvements:

    * Easier management of database table exceptions and compound indexes.
    * CLI support. Now for just asking for user ids to merge, but it nows allows you to build your own CLI scripts for autmoatic mergings, very very easy.
    * No more external logging is required. Any merging action is automatically recorded into the database for further reference. To do so, two links are shown in the settings: one for merging and another one for seeing last merging actions and their status.
    * Code has been rewritten in most of parts to enable the above functionality and also to be more Moodle-friendly, even thought it always can be improved, for sure.

    And the last one, remember that this plugin is no longer a report, but a tool for administrators, as you can see from source code.

    Hoping to see feedback and experiences of its use big grin


  • Fri, Jan 17, 2014, 5:56 PM
    Hello all,

    As stated by Jordi above, this plugin has now been replaced by the tool_mergeusers plugin and is not maintained any more.

    The new plugin should be available here: shortly and is already available in GitHub here:
  • Mon, Jan 20, 2014, 8:03 PM
    Great Nicolas!
  • MD shot of me from his iphone4
    Wed, Feb 12, 2014, 1:48 PM
    thanks for tool_mergeusers , i suggest updating the description on top to reflect this more prominently.
  • Thu, Feb 13, 2014, 6:20 PM
    Hi all,

    All administrators who installed this plugin are kindly invited to replace it by this:, since the report_mergeusers plugin is no longer maintained.

    In addition, there is a lot of new functionality (CLI scripts, merging reports stored in database, etc See the included README.txt for more details).


  • Thu, Jan 8, 2015, 5:04 AM
    Hello there,
    We want to use this plugin, but our Moodle Partner is telling us it is given index problems. Not sure what they mean by that. Can someone explain.

    From our point of view, the merge works great, all of content from account A does get transfered to account B, the attendance, evlauation and reports are moved as well.

  • Thu, Jan 8, 2015, 5:07 AM
    What are the major issues - blockers to look out for? And tare they surmontable?
  • Thu, Jan 8, 2015, 4:04 PM
    Hello Marie-Pierre,

    As stated by Jordi above, this plugin has been obsoleted. Please refer to its successor, .
1 2
Please login to post comments