Your Moodle version

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.
Moodle 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8

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 Adrian Sutantio
    Wed, Feb 3, 2016, 1:30 PM
    Hi there,

    Thank you for the amazing plugin. We have used this several times when we were on Moodle 2.7. We have just upgraded our Moodle to 2.9 and I got this error when tried to use the plugin

    Exception thrown when merging: 'Error reading from database".
    Unknown column 'id' in 'field list'
    #0 /home/ddd/public_html/lib/dml/mysqli_native_moodle_database.php(1080): moodle_database->query_end(false)
    #1 /home/ddd/public_html/admin/tool/mergeusers/lib/table/generictablemerger.php(65): mysqli_native_moodle_database->get_records_sql('SELECT id FROM ...')
    #2 /home/ddd/public_html/admin/tool/mergeusers/lib/mergeusertool.php(281): GenericTableMerger->merge(Array, Array, Array)
    #3 /home/ddd/public_html/admin/tool/mergeusers/lib/mergeusertool.php(216): MergeUserTool->_merge('1709', '14610')
    #4 /home/ddd/public_html/admin/tool/mergeusers/index.php(135): MergeUserTool->merge('1709', '14610')
    #5 {main}

    Can you help please?
  • Picture of Jordi Pujol-Ahulló
    Wed, Feb 3, 2016, 3:33 PM
    Hi Adrian,

    I've just created

    This afternoon I'll be back to you.

  • Picture of Jordi Pujol-Ahulló
    Wed, Feb 3, 2016, 3:36 PM
    Hi all!

    We are happy to see that our plugin is one of the 2015 favourite Moodle plugins!!

    Follow the post on:

    Thanks Gavin, thanks Moodle, thanks Community, for this honour!!
  • Picture of Jordi Pujol-Ahulló
    Wed, Feb 3, 2016, 3:57 PM
    Hi again Adrian,

    Taking a closer look at your message, I need more details on what is the problem about, mainly the database table where the "id" column does not exist. Have you any custom plugin/development/?? which is using a table without an "id" column?

    It is very strange, since Moodle defines (via XMLDB editor) always an "id" column. Can you search for tables without "id" column?

    You can use this select to get the list of them:

    select distinct c.table_name from Information_schema.columns c left join (select table_name from information_schema.columns where column_name like 'id') t ON t.table_name = c.table_name WHERE t.table_name IS Null and c.table_name like 'mdl_%';

    replace "mdl_" for your own table prefix.

    Thanks in advance!
  • Picture of Chris Chapman
    Wed, Mar 2, 2016, 10:17 PM
    Hi all ,

    Thanks for this plugin is a true life-saver! been using it with 2.6 and 2.9 since August 2015, no hitches till now. I have a user to merge but throwing this error Exception thrown when merging: 'Error writing to database".
    Duplicate entry '11079-13879-0-0' for key 'mdl_assisubm_assusegroatt_uix'

    But I cant find the offending entry in any of the tables other than tool_mergeusers to change it...

    Any suggestions?
  • Picture of Chris Chapman
    Wed, Mar 2, 2016, 11:33 PM
    Managed to rectify the issue - removed all records in for the User 13879 in assign_submissions. worked fine then, User must have submitted the same assignment in both accounts...
  • Picture of C Behan
    Mon, Apr 18, 2016, 6:59 PM
    Hi Nicholas, Jordi,

    Thank you for this excellent plugin. I'm wondering if you're planning to upgrade it for Moodle 3.0?

    Thanks, Catherine
  • Picture of Jordi Pujol-Ahulló
    Mon, Apr 18, 2016, 7:11 PM

    Thanks for asking and for your interest!

    Actually, the source code is already updated to work on Moodle 3 (see in the branch "master"). We only need to update this site to reference to the last code version.

    Thanks for pointing it out!


  • Picture of C Behan
    Wed, Apr 20, 2016, 12:06 AM
    Thanks Jordi smile
  • My son
    Mon, Jun 20, 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, Jun 20, 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, Jul 21, 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, Jul 21, 2016, 5:02 PM
    Hello Anna,

    Yes, indeed it should. Thanks for reporting back.

  • Picture of Austin Powell
    Wed, Sep 7, 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, Oct 6, 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.
1 2 3 4 5 6
Please login to post comments