How to replace an user

How to replace an user

by Alessio Niespolo -
Number of replies: 8

I would like to duplicate some users in Moodle. It means these users must preserve the same information of the original users (personal data, enrolments, roles, rights, etc.). Only two information should be different: the Username and the Email address. The accounts have the Shibboleth authentication method. How could I duplicate the users?

Average of ratings: -
In reply to Alessio Niespolo

Re: How to replace an user

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I can't think of any way to do that. It's a very unusual request.
In reply to Howard Miller

Ri: Re: How to replace an user

by Alessio Niespolo -
Unfortunately this is the request of my client, because there are a lot of users that worked for the xxx company and now work for the yyy company. This means their emails "@xxx.it" has been replaced with "@yyy.it". And the same for the Username that is equal to the email, beacause it's synchronized with the upn in AD(Active Directory). The "@xxx.it" account will be removed in AD and they'll use only the "@yyy.it" account now.
In reply to Alessio Niespolo

Re: Ri: Re: How to replace an user

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Script something to change the username and email directly in the database? Creating duplicate accounts would be well down my list of possible solutions for that problem.
Average of ratings: Useful (1)
In reply to Alessio Niespolo

Re: Ri: Re: How to replace an user

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Let's say you have success, for example Alissio.xxx.it, and Alissio.yyy.it. Then what? What do you hope to accomplish? Incidentally, I don't know about the Shibboleth authentication method, so if my question is off target, ignore it.
In reply to Alessio Niespolo

Re: Ri: Re: How to replace an user

by R V Iyengar -
Since users are available in AD, Use OAUTH2 with myname@yyy.it
In reply to Alessio Niespolo

Re: Ri: Re: How to replace an user

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
  1. Go to Site admin > Users > Bulk User Actions. 
  2. Filter on email contains xxx.it
  3. Download those users that a spreadsheet

In the spreadsheet…
  1. Rename the username column to “oldusername”
  2. Correct the email addresses using search and replace
  3. Copy that email column to a new column and call that “Username”
If they are still using the same authentication method, that all you need to do with the spreadsheet. If not, you can add a column for “auth” too and change that for each person if  needed.

Back in Moodle,
  1. Go to Site admin > Users > Upload users
  2. Select “Update existing users only” and “Override with file”
  3. Upload

The whole process should take you less than 10 minutes smile


See https://docs.moodle.org/39/en/Upload_users


Average of ratings: Useful (3)
In reply to Jon Bolton

Ri: Re: Ri: Re: How to replace an user

by Alessio Niespolo -
Is it possible to include an "or condition" in the "Bulk User Actions"? For example, I would like to filter by searching a list of usernames (ex. username1@xxx.it, username2@xxx.it and so on) and not all the users with username "@xxx.it".
In reply to Alessio Niespolo

Re: Ri: Re: Ri: Re: How to replace an user

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
No - but the easiest solution is to filter in Moodle on all your @xxx.it addresses and download all of them, and then do your more detailed filtering in Excel.