Your Moodle version

Reports: Merge user accounts

Maintained by Picture of Nicolas Dunand 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.

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).


Picture of Nicolas Dunand
Nicolas Dunand (Lead maintainer): author
Mike Holzer
Mike Holzer: author
Picture of Forrest Gaston
Forrest Gaston: author
Picture of Jordi Pujol-Ahulló
Jordi Pujol-Ahulló: author
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Dave Arnold
    Thu, Mar 7, 2013, 11:26 PM
    Thanks for the heads up. I'm testing it out now and checking to see if we have any lessons to be concerned with.
  • Picture of David Bezemer
    Tue, May 14, 2013, 9:30 PM
    does this script also merge the private/personal files of a specific user? otherwise I see a potential problem with the files of assignments that came from a users private files (ie, no access to those files for user B) Also is it possible to create functionality to merge everything back into Account A and delete account B?
  • Picture of Nicolas Dunand
    Wed, May 15, 2013, 4:26 PM
    No, the script does not yet take files into account. This is the next feature that will be implemented.
  • Picture of Steve Yoss
    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!!



  • Picture of Nicolas Dunand
    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.
  • Picture of Steve Yoss
    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!

  • Picture of Steve Yoss
    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.

  • Picture of David Gilpin
    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?
  • Picture of Jordi Pujol-Ahulló
    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.

  • Picture of Nicolas Dunand
    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
  • Picture of Jordi Pujol-Ahulló
    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


  • Picture of Nicolas Dunand
    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:
  • Picture of Jordi Pujol-Ahulló
    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.
  • Picture of Jordi Pujol-Ahulló
    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).


1 2
Please login to post comments