Merge user accounts

Administration tool ::: tool_mergeusers
Maintained by Jordi Pujol-Ahulló, Nicolas Dunand
This administration tool will merge two Moodle user accounts into one.
Latest release:
2652 sites
3k downloads
89 fans
Current versions available: 6

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.

Help us

We do not give support in the comments section below. For any issue on the plugin, please, refer to GitHub and:

  1. Check if a related issue is already created with the exact detail or similar to the failure you're facing. Add your own experience too. Or
  2. Build a new issue clicking on https://github.com/jpahullo/moodle-tool_mergeusers/issues/new and add the necessary detail to replay the failure or the trace to help you out, and/or
  3. Contribute to the plugin with a PR addressing the problem you're solving.

Help us manage this plugin in a more comfortable way in our spare time by using GitHub. Thanks in advance!

Potential privacy issues

This plugin does not store any personal data.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3

Contributors

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

Comments RSS

Comments

  • Tyreese Davis
    Wed, 7 Oct 2015, 10:25 PM
    Good morning currently using the merge tool on Moodle 2.8, Version Release 1.10.2 (Build: 2015022001)
    Seeing the following
    Exception thrown when merging: 'Error writing to database".
    Exception thrown when merging: 'Error writing to database".
    Duplicate entry '27054-3022-0-0' for key 'mdl_assisubm_assusegroatt_uix'
    Trace:
    #0 /moodle_sand/lib/dml/mysqli_native_moodle_database.php(974): moodle_database->query_end(false)
    #1 /moodle_sand/admin/tool/mergeusers/lib/table/generictablemerger.php(225): mysqli_native_moodle_database->execute('UPDATE mdl_assi...')
    #2 /moodle_sand/admin/tool/mergeusers/lib/table/generictablemerger.php(80): GenericTableMerger->updateRecords(Array, Array, 'userid', Array, Array)
    #3 /moodle_sand/admin/tool/mergeusers/lib/mergeusertool.php(281): GenericTableMerger->merge(Array, Array, Array)
    #4 /moodle_sand/admin/tool/mergeusers/lib/mergeusertool.php(216): MergeUserTool->_merge('3022', '44677')
    #5 /moodle_sand/admin/tool/mergeusers/index.php(135): MergeUserTool->merge('3022', '44677')
    #6 {main}
  • Mono Lith
    Fri, 6 Nov 2015, 6:29 PM
    Hi!

    This is a very useful tool.

    Looking forward for 2.9 compatibility results!

    Regards,

    Monolith.
  • Anna Krassa
    Wed, 25 Nov 2015, 4:30 PM
    Hello Nicolas and Jordi,

    Thank you very much for this great tool! We use it a lot in our site.

    +1 for Arto's suggestion on setting up the capabilities. I also want to give merging rights to Managers. Of course I share Jordi's worries about safety, but imagine how risky it would be if instead of allowing Managers merge users, we have to change the Manager's role into Admin!

    Plus, I don't know if this is the "default" attribute, but in our site, whenever we merge two users, the account to be removed is not deleted but suspended. Which is also a very good "just in case" solution...

    I have already said in GitHub, that I am not a developer but I am very interested in this feature and I 'll be glad to assist if I can.

    Best wishes,
    kan
  • Anna Krassa
    Fri, 8 Jan 2016, 4:11 PM
    Hello everyone,

    I am using User Merge in Moodle 3.0 now and I confirm that everything works nicely.

    There is one case though that gives me the following error, but I was receiving the same error in Moodle 2.8.

    ***

    Some error occurred:

    Exception thrown when merging: 'Error writing to database".

    Trace:
    #0 /home/learn/public_html/lib/dml/pgsql_native_moodle_database.php(244): moodle_database->query_end(false)
    #1 /home/learn/public_html/lib/dml/pgsql_native_moodle_database.php(682): pgsql_native_moodle_database->query_end(false)
    #2 /home/learn/public_html/admin/tool/mergeusers/lib/table/generictablemerger.php(225): pgsql_native_moodle_database->execute('UPDATE mdl_cour...')
    #3 /home/learn/public_html/admin/tool/mergeusers/lib/table/generictablemerger.php(80): GenericTableMerger->updateRecords(Array, Array, 'userid', Array, Array)
    #4 /home/learn/public_html/admin/tool/mergeusers/lib/mergeusertool.php(281): GenericTableMerger->merge(Array, Array, Array)
    #5 /home/learn/public_html/admin/tool/mergeusers/lib/mergeusertool.php(216): MergeUserTool->_merge('6783', '6412')
    #6 /home/learn/public_html/admin/tool/mergeusers/index.php(135): MergeUserTool->merge('6783', '6412')
    #7 {main}


    Merge failed!
    Your database engine supports transactions. Therefore, the whole current transaction has been rolled back and no modification has been made to your database.

    ***

    Unfortunately the debugging option didn't gave us any direction on what to fix on database, could you please advice?

    Thank you in advance,
    kan
  • Jordi Pujol-Ahulló
    Fri, 8 Jan 2016, 6:31 PM
    Hi Kan!

    Thank you very much for reporting.

    Please, report the line between your "Exception thrown...." and "Trace:", because there appears the key message for solving your conflict. It is an error on an UPDATE, so there would be something about compound keys that an UPDATE produces duplicate keys.

    Keep in touch,

    Jordi

  • Betsy Springer
    Sun, 24 Jan 2016, 5:32 AM
    do you know if this can be used if we use joomdle authentication?
  • Jordi Pujol-Ahulló
    Mon, 25 Jan 2016, 3:17 PM
    Hi!

    I suppose that joomdle authentication is just another kind of authentication plugin, and so, it will appear in the column user.auth with the corresponding value. Therefore, beforehand, and having no prior experience on that, I suppose it will work straight away, as in other Moodle instance. The only think you have to take care of, is running it in some test environment and check that the auth type remains the corresponding for joomdle after merging.

    Always make some test NOT IN PRODUCTION environment, in this kind of scenarios. First test it, and then you could deploy it into production, as you would do with any other kind of plugin.

    It will be nice if you come back with the results.

    Thank you for contacting us!

    Jordi
  • Adrian Sutantio
    Wed, 3 Feb 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'
    Trace:
    #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?
  • Jordi Pujol-Ahulló
    Wed, 3 Feb 2016, 3:33 PM
    Hi Adrian,

    I've just created https://github.com/ndunand/moodle-tool_mergeusers/issues/108.

    This afternoon I'll be back to you.

    Jordi
  • Jordi Pujol-Ahulló
    Wed, 3 Feb 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: https://moodle.org/mod/forum/discuss.php?d=325804

    Thanks Gavin, thanks Moodle, thanks Community, for this honour!!
  • Jordi Pujol-Ahulló
    Wed, 3 Feb 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!
  • Chris Chapman
    Wed, 2 Mar 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?
  • Chris Chapman
    Wed, 2 Mar 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...
  • C Behan
    Mon, 18 Apr 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
  • Jordi Pujol-Ahulló
    Mon, 18 Apr 2016, 7:11 PM
    Hi!

    Thanks for asking and for your interest!

    Actually, the source code is already updated to work on Moodle 3 (see https://github.com/ndunand/moodle-tool_mergeusers in the branch "master"). We only need to update this site to reference to the last code version.

    Thanks for pointing it out!

    Best,

    Jordi
Please login to post comments