Import User Profile Question

Import User Profile Question

by David Marosek -
Number of replies: 8
Hi, I'm testing right now to import a user text file(about 2000 users) into Moodle 1.9.3. I successfully imported the users in, but the question I have is is there a switch that can be put in the text file that would force the user to change their password when they logged in the first time. I know that if a user is put in manually, you can check the box to force the password change, but I didn't know if you could do that with importing the text file.

Thanks!!
Average of ratings: -
In reply to David Marosek

Re: Import User Profile Question

by Dave Shearan -

Hi David,

This is something that we wanted as well so I changed the uploadusers script to do it. I bet there is a more elegant way of doing this but from our point of view every time we uploaded users I wanted to make sure that they would be forced to change their password on next use.

If you are in the same boat then you could also make this change as described here:

edit the file moodle\admin\uploadusers.php (using a simple text editor)

search for $usersnew++ and then add the two lines shown here (the comment line and the set_user_preference link) so that the code now looks like the following: (with or without the line spacing I have shown)

    $usersnew++;

    // Hack to force password change for all new users in the upload csv file
    set_user_preference('auth_forcepasswordchange', 1, $user->id);

    if ($createpasswords and empty($user->password)) {

Now save the file and the test it

If you are going to make changes to the code like this then keep a good record of what you have done so that you can apply the same changes when you upgrade to a new version

Hope this works for you

Dave

Average of ratings:Useful (1)
In reply to David Marosek

Re: Import User Profile Question

by Martin Huntley -
The simple way is to initially assign them (in your import file) the special password "changeme".

See http://docs.moodle.org/en/admin/uploaduser.
In reply to Martin Huntley

Re: Import User Profile Question

by David Marosek -
Ah, this is wonderful. Thank you! I can take the text import file our help desk sends me, import it into Excel, make the changes, then import it back into Text. smile This should work out well.

Thanks!
In reply to Martin Huntley

Re: Import User Profile Question

by Carl Hodkinson -
The trouble with changeme as a password is that if you have a load of users where their usernames are prepared by using formulae a spreadsheet, e.g. their initial + lastname concatenated together, e.g. chodkinson, then everyone can work this out how to get into each other peoples' account and basically disable them by changing the passwords. You only need one idiot with an attitude in your user base and your administration shoots right up! angry

Dave has sorted out the perfect solution for his organisation (and nice one - works a treat! approve) the ability to inform users of their username and some type of generated but unique password and when they go into Moodle for the first time, it makes them change it. I have though two issues with this;
  1. it isn't an option as it forces this feature for all uploaded accounts (please correct me if I'm wrong) but you might not want it to happen all the time, e.g. for test accounts in a training setting.
  2. it isn't functionality that exists in core Moodle - upgrade time is bad enough without having to redo all the little hacks and tweaks you have done since the last time you upgraded
What would be great is if in the csv of the users you are wanting to upload, you could either add an additional field, like you can for emailstop, mailformat and other profile fields or you could have a checkbox in the options in the upload procedure. This would determine whether or not the user had to change their password when they go in for the first time.

It's a simple idea so the coding can't be hard!! wink

Any thoughts?
In reply to Carl Hodkinson

Re: Import User Profile Question

by Carl Hodkinson -
I've got so enthused about this, I've put it into the tracker as a feature request.

Please vote for it!! wink

MDL-20679