Moodle plugins directory: Merge user accounts | Moodle.org
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:
2610 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:
- 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
- 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
- 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!
Useful links
Contributors
Jordi Pujol-Ahulló (Lead maintainer): author
Nicolas Dunand: author
Please login to view contributors details and/or to contact them
Our Moodle Partner is having issues with some indexes. Can I foward the error messages and see if you can help fix them? We really like this tool. It is a great innovation for moodle!
thanks
Okay, please forward the error messages. The best way is to create an issue on GitHub at https://github.com/ndunand/moodle-tool_mergeusers/issues
For further reference, these results are recorded in the log id 3.
Some error occurred:
Exception thrown when merging: 'Error reading from database".
Unknown column 'id' in 'field list'
Trace:
#0 C:\Websites\moodle\lib\dml\mysqli_native_moodle_database.php(1014): moodle_database->query_end(false)
#1 C:\Websites\moodle\admin\tool\mergeusers\lib\table\generictablemerger.php(65): mysqli_native_moodle_database->get_records_sql('SELECT id FROM ...')
#2 C:\Websites\moodle\admin\tool\mergeusers\lib\mergeusertool.php(277): GenericTableMerger->merge(Array, Array, Array)
#3 C:\Websites\moodle\admin\tool\mergeusers\lib\mergeusertool.php(212): MergeUserTool->_merge('535', '1331')
#4 C:\Websites\moodle\admin\tool\mergeusers\index.php(135): MergeUserTool->merge('535', '1331')
#5 {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.
In /admin/tool/mergeusers/lib/mergeusertool.php line 135, if you take this code here:
$this->sqlListTables = 'SHOW TABLES like "' . $CFG->prefix . '%"';
and replace it with this:
$this->sqlListTables = "SHOW FULL TABLES WHERE `Tables_in_moodle` LIKE '" . $CFG->prefix . "%' AND `Table_type` = 'BASE TABLE'";
it should avoid attempting to set the values of records in views because it filters all views out from the results.
Once I did this then everything worked nicely!
Thanks for this tool!
Perry
I'm adding this to the github as an issue to be included asap.
My worries are about the SQL proposed, that it should be tested in all testbeds (mainly mysql, oracle and postgresql).
Thanks again! Please, keep testing, commenting and contributing!
Best,
Jordi
Could this tool be allowed also for manager role? Managers have access to all other links on Users > Accounts menu anyway. Maybe a new capability?
I imagine we could easily add a specific capability for that, but then of course you would need to be manager at the site level for that.
What do you think, Jordi?
I like this proposal for the new capacity. However, I need to check it and remember who can see the administration menu or parts of it.
In the other hand, we should remember that merging a user is a highly critical operation and it should not be available for a broad number and kind of users (in my honest opinion). This is the counterpart that makes me think about the opposite direction (i.e., a new capacity should be not available, and only for site administrators).
Above all, for the sake of flexibility and a broader adoption, I think we should include a new capability. In particular, two capabilities: one for merging users, and another one to see logs. This way, for forensic uses, it would be very interesting to allow managers to check what happened to a given user.
If you agree, we could add it as a new issue in the github.
Thanks for your comments! Always are welcome!
Jordi
We have updated the plugin version to the current last 1.10.1. This is a minor version not including new features, but several solutions for bugs like these ones among others:
1. Detected new compound indexes.
2. Added support for mariadb (mysqli) and mssql (sqlsrv) database types.
3. Revisited sqls to work with sqlsrv and postgresql
4. Renaming classes and revisited class autoloading for compatibility on upper versions of Moodle.
Thanks to all of you that contributed in any way, not only for reporting bugs and problems, but also for contributing with a patch to solve them.
Keep tune in!
Jordi
We have updated this plugin to a last release 1.10.2 to solve a bug included in the prior 1.10.1.
Sorry for that. If you have downloaded the 1.10.1, you have to download the last release 1.10.2.
Thanks for all your contributions!
Jordi
We will be checking for its compatibility with M2.9 and make it public as soon as possible.
Thanks for your interest. We will inform it here.
Jordi
i have tried to use with 2.9 but it throws up an error as follows
For further reference, these results are recorded in the log id 2.
Some error occurred:
Exception thrown when merging: 'Error writing to database".
Trace:
#0 /var/www/moodle/lib/dml/pgsql_native_moodle_database.php(244): moodle_database->query_end(false)
#1 /var/www/moodle/lib/dml/pgsql_native_moodle_database.php(682): pgsql_native_moodle_database->query_end(false)
#2 /var/www/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(225): pgsql_native_moodle_database->execute('UPDATE mdl_cour...')
#3 /var/www/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(80): GenericTableMerger->updateRecords(Array, Array, 'userid', Array, Array)
#4 /var/www/moodle/admin/tool/mergeusers/lib/mergeusertool.php(281): GenericTableMerger->merge(Array, Array, Array)
#5 /var/www/moodle/admin/tool/mergeusers/lib/mergeusertool.php(216): MergeUserTool->_merge('15104', '2202')
#6 /var/www/moodle/admin/tool/mergeusers/index.php(135): MergeUserTool->merge('15104', '2202')
#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.
Hope this helps
Regards
Gary
I created an issue at: https://github.com/ndunand/moodle-tool_mergeusers/issues/102
You can review the resolution status there.
Remember that we maintain this plugin at our spare time. As soon as possible we get it working on M2.9, I will inform you.
By the way, could you find and provide us the whole SQL sentence about the "UPDATE mdl_cour..." ? I think you will be able to find it in the log record stated with id 2.
Thanks in advance!!
Jordi