Merge User Account Script

2908

lanes_merge_road_sign_19531Please note that this is an advanced tool that will require access to your database (which you should backup first before executing any script)

WIRIS

Have a lot of users that have signed up with more than one email or were inadvertently added more than once to a site and now both have user data?  Have no fear, here’s a contributed script that you might be able to use to solve your duplicate user situation. Read more here https://moodle.org/plugins/view.php?plugin=report_mergeusers

The Merge User report/script “will merge two Moodle user accounts, “user A” and “user B”. The intent of the script 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.”

Check out the readme file for more important information and a few exceptions where the script doesn’t change anything (https://github.com/ndunand/moodle-mergeusers),

This script will merge two Moodle user accounts, “user A” and “user B”. The intent of the script 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. The basic function of the script is to loop through the tables and update the userid of every record from user A to user B. This works well for most tables.

So once complete, what was once two user accounts is now one account with all of the user data combined. Handy.