Admin tools: Merge user accounts

Maintained by Picture of Nicolas Dunand Nicolas Dunand, Picture of Jordi Pujol-Ahulló Jordi Pujol-Ahulló
This administration tool will merge two Moodle user accounts into one.
473 sites
31 fans
Moodle 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2

The intent 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.

This tool replaces the old report_mergeusers, which is now obsolete.


Screenshot #0
Screenshot #1
Screenshot #2


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

Comments RSS

Show comments
  • Picture of C Behan
    Wed, 20 Apr 2016, 12:06 AM
    Thanks Jordi smile
  • My son
    Mon, 20 Jun 2016, 3:52 PM

    I've just upgraded to Moodle 3.1+ and I'm seeing this message in the Notifications:
    The following plugins in your system are using Events 1 API deprecated handlers: 'tool_mergeusers'. Please, update them to use Events 2 API.

    I'm guessing it's not a problem right now but perhaps in the future?

  • Picture of Jordi Pujol-Ahulló
    Mon, 20 Jun 2016, 4:33 PM
    Thanks for your comments!

    I'll keep an eye on this. In fact, there is an issue in our github repository addressing this issue.


  • Picture of Anna Krassa
    Thu, 21 Jul 2016, 4:41 PM
    Hello everyone,

    This is just to inform that I have tested the latest version of the plugin (1.10.2) in a Moodle 3.1 site and it works as expected.

  • Picture of Nicolas Dunand
    Thu, 21 Jul 2016, 5:02 PM
    Hello Anna,

    Yes, indeed it should. Thanks for reporting back.

  • Picture of Austin Powell
    Wed, 7 Sep 2016, 12:43 AM
    We just updated to Moodle 3.1 and updated the code for the plugin from the github master branch as described.
    When trying to merge two users though, we're getting a "Coding error detected" message. The stacktrace is copied below. Any ideas? Let me know if I should post this on your Github as an issue instead.

    Coding error detected, it must be fixed by a programmer: moodle_database::update_record_raw() id field must be specified.
    More information about this error
    ×Debug info:
    Error code: codingerror
    ×Stack trace:
    line 1376 of /lib/dml/mysqli_native_moodle_database.php: coding_exception thrown
    line 1432 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->update_record_raw()
    line 57 of /admin/tool/mergeusers/lib/events/olduser.php: call to mysqli_native_moodle_database->update_record()
    line ? of unknownfile: call to tool_mergeusers_old_user_suspend()
    line 3955 of /lib/deprecatedlib.php: call to call_user_func()
    line 4216 of /lib/deprecatedlib.php: call to events_dispatch()
    line 809 of /lib/classes/event/base.php: call to events_trigger_legacy()
    line 231 of /admin/tool/mergeusers/lib/mergeusertool.php: call to core\event\base->trigger()
    line 135 of /admin/tool/mergeusers/index.php: call to MergeUserTool->merge()
  • I don't realy look like this.Honest!
    Thu, 6 Oct 2016, 9:01 PM
    Sorry if this is already on the comments list.
    I added it but it either didn't save or I can't find it.

    I've just upgraded to Moodle 3.1 and I'm seeing this message in the Notifications:

    The following plugins in your system are using Events 1 API deprecated handlers: 'tool_mergeusers'. Please, update them to use Events 2 API.

    I downloaded the latest version from Git but made no difference.
  • Picture of Mehmet Sen
    Wed, 2 Nov 2016, 12:09 AM
    I guess the current zip version is not compatible with the 3.1 version when installing the with zip file?

    It gives the following error:

    Validating tool_mergeusers ... Error
    [Error] Extracted file not found [{"file":"mergeusers\/styles.css"}]
    Installation aborted due to validation failure
  • Picture of Nicolas Dunand
    Wed, 2 Nov 2016, 12:35 AM
    Hi Austin,

    Sorry about the delay. Yes, please post this issue to GitHub as I can't do it right now. There it should be reviewed and fixed eventually,
  • Picture of Nicolas Dunand
    Wed, 2 Nov 2016, 12:36 AM

    Indeed this is a lower priority issue. It does not alter functionality yet but will in future versions of Moodle. We're looking into it and this will be corrected to fully support upcoming Moodle version as they are released.
  • Picture of Nicolas Dunand
    Wed, 2 Nov 2016, 12:38 AM

    This should in fact work but hasn't been tester with Moodle's own plugin installer. You should be able to install copying files to the file system without any issues though.
  • Picture of Mehmet Sen
    Wed, 2 Nov 2016, 2:50 AM
    Thanks Nicolas, copy pasting the folder worked out!
    Hopefully "Events 1 API deprecated... " warning would be corrected in next release as you indicated above.
  • Picture of Jordi Pujol-Ahulló
    Thu, 3 Nov 2016, 11:39 PM
    Hi Adrian (,

    Could you please check the conversation at and say something with respect to your question?

    Thanks in advance!

  • Picture of David Cunningham
    Wed, 1 Feb 2017, 6:04 PM

    I have recently tried installing this Plug in on Moodle 2.8 and once I have installed the plug in and try to run it, I receive the following error message, Exception thrown when merging: 'Error reading from database".
    Unknown column 'id' in 'field list'
    #0 /var/www/html/moodle/lib/dml/mysqli_native_moodle_database.php(1080): moodle_database->query_end(false)
    #1 /var/www/html/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(75): mysqli_native_moodle_database->get_records_sql('SELECT id FROM ...')
    #2 /var/www/html/moodle/admin/tool/mergeusers/lib/mergeusertool.php(288): GenericTableMerger->merge(Array, Array, Array)
    #3 /var/www/html/moodle/admin/tool/mergeusers/lib/mergeusertool.php(216): MergeUserTool->_merge('3110', '11041')
    #4 /var/www/html/moodle/admin/tool/mergeusers/index.php(135): MergeUserTool->merge('3110', '11041')
    #5 {main}

    Can anybody lend a helping hand if they have any idea on what the problem could be?
  • Picture of Jordi Pujol-Ahulló
    Wed, 1 Feb 2017, 7:32 PM
    Hi David,

    I think this is due to some local plugin you have installed that does not follow the Moodle standards, and some table from your database does not have a column named "id". Is that possible? The pity is that the error does not show which is the specific table that the process is dealing with.

    Could you check that?


1 2 3 4 5 6
Please login to post comments