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.
848 sites
42 fans

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
Screenshot #3


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
Picture of RISET Université de Lausanne
RISET Université de Lausanne: Supporting institution
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Jordi Pujol-Ahulló
    Tue, 27 Feb 2018, 2:05 AM
    Hi! Several rounds ago, and also for the round of January-July 2018 we are proposing this issue as a MUA project here:

    Looking to see you there and also voting!
  • Picture of Beto de Oliveira
    Tue, 13 Mar 2018, 4:48 AM

    Does the plugin works with external db accounts?
  • Picture of Constance Horne
    Tue, 13 Mar 2018, 4:50 AM
    It merges two users in a moodle database.
  • Picture of Jordi Pujol-Ahulló
    Tue, 13 Mar 2018, 4:06 PM

    Thanks Constance for the reply.

    Hi Beto. This plugin is a Moodle plugin. As such, it only operates on the Moodle database, and not on external databases.

    Thanks to all of you.
  • Renaat
    Wed, 23 May 2018, 9:26 PM
    Moodle 3.5 compatible and no privacy provider?

    As a result the phpunit tests fail:

    provider_testcase::test_all_providers_compliant with data set "tool_mergeusers" ('tool_mergeusers', 'tool_mergeusers\privacy\provider')
    Failed asserting that false is true.


    To re-run:
    vendor/bin/phpunit provider_testcase privacy/tests/provider_test.php
  • Picture of Jordi Pujol-Ahulló
    Wed, 23 May 2018, 11:12 PM
    You're right. Sorry about that. We will check it.
  • Picture of Zackary Bennett
    Tue, 3 Jul 2018, 11:46 PM
    I used your tool to try to combine two accounts. However, an error is returned, and I was hoping to get some input on what it means.

    Exception thrown when merging: 'Error reading from database"
    Table 'moodle.mdl_ast_access1095' doesn't exist

    I looked through the tables listed on moodle's site (for reference) and the ones I can see in MySQL workbench, and that table doesn't exist.

    Does that mean that the tool is looking for that table, can't find it, and is throwing an error? Is there anything I can do to work around this issue?
  • Picture of Jordi Pujol-Ahulló
    Wed, 4 Jul 2018, 12:11 AM
    Hi Zackary!

    Thanks for reporting.

    It is very very weird that this plugin tries to look for a table that actually does not exist. Most of all because it looks for all tables in runtime and then iterates for all of them.

    However, if this is the case (we should take a look why it is happenning), you can take a turnaround and let the plugin prevent processing that table. Let's see:

    Taking a look at what we talk about here: we can add ad-hoc configuration for every Moodle instance independently.

    I recommend you to place the file "admin/tool/mergeusers/config/config.local.php" with the following content:

    ========================= <?php

    return array(
    'exceptions' => array(
    'ast_access1095', //don't place the table prefix on the table name

    If you have this file already created, for whatever reason, you should have to merge the content. Otherwise, you just create the file with the above content.

    Just tell us what it's going on!


  • Picture of Jordi Pujol-Ahulló
    Wed, 4 Jul 2018, 12:12 AM
    Sorry, the content should be this (without the "=" strings):



    return array(
    'exceptions' => array(
    'ast_access1095', //don't place the table prefix on the table name


    Hope that helps!
  • Picture of Zackary Bennett
    Sat, 7 Jul 2018, 12:33 AM
    Thank you Jordi! Adding that exception did the trick. So simple and effective.
  • Picture of Evan Abbey
    Thu, 12 Jul 2018, 11:35 PM
    Jordi, we have used the merge users plugin for a while (since it was a report). We just noticed that it is not merging grades within a gradebook when both of the student accounts were enrolled. We are on Moodle version 3.5.0. There are no errors or anything within debugging to indicate that something is wrong that I can see.

    • Is this the intended outcome? I might have missed that the plugin always did this in the past, and just thought it was merging them. I attempted to rollback the plugin, and that made no difference.

    • Right now, our log output for a merge shows these two lines related to grades:
    DELETE FROM mdl_grade_grades WHERE id IN (38548, 38547, 38549)
    UPDATE mdl_grade_grades_history SET userid = '9232' WHERE id IN (137943, 137944, 137945, 137946)

    Do I have a setting incorrect? I have been leaving the default settings for the plugin, as they have worked for me in the past.

    Thank you
  • Picture of Jordi Pujol-Ahulló
    Wed, 18 Jul 2018, 12:32 AM
    Thanks @Zackary for the feedback. We are happy to make it work as a charm.
  • Picture of Jordi Pujol-Ahulló
    Wed, 18 Jul 2018, 12:39 AM
    Hi @Evan!

    Thanks for giving us feedback.

    Please, check if this issue is related to your case:

    If so, add there your comments to get them there and be complementary to what already exists. Otherwise, in case of doubt, make a new issue with your text.

    Depending on what matches best, it may be an underlying bug long time existing or it may be a new issue for working it on Moodle 3.5. Your information there would be necessary to match the case. Put that information, please, on github.

    Thank you for sharing,

  • Picture of Evan Abbey
    Wed, 18 Jul 2018, 12:41 AM
    Will do, thx Jordi
1 2 3 4 5 6 7 8
Please login to post comments