we are looking for a solution to synchronize the moodle user pictures with the user pictures from our intranet. The bulk upload is not really suitable for us.
I am glad for any tips or hints.
Hi Luke, we have our user pictures stored in a separate external database and we just ended up creating a bash script that cron runs periodically to copy pictures out from that database, name them appropriately and upload them to Moodle using the /admin/cli/updatepics.php script. See: https://docs.moodle.org/27/en/Administration_via_command_line#Update_user_pictures_via_command_line
The script has 3 actions that it runs.
1) Exports the user pictures from the database into a folder, naming them with the usernames of the users they belong to. These have to match the Moodle usernames.
2) Copies them to the right place where both the account running the cron and Moodle can access the folder (we place it a new folder in the Moodle Data Store path). It also cleans up the old batch, so that any pictures that have changed for an existing user are also updated.
3) Runs the updatepics.php script, with the --dir= argument set to the folder that contains the pictures.
For #3, you should see output for each user that is updated, ie: ++ Picture updated for user email@example.com. ++
We run it every 20 minutes or so, but it could be run once a day, once a week or whatever you feel is appropriate. The majority of the work involved in developing the script was on actions #1 and #2, since that completely depends on the application storing the pictures and where it is located.
Thanks for sharing this; I think I may well try and replicate this at my school!
Hi Mathew I just finished testing and documenting this today. We use a Management Information System called iSAMS so my documentation is very specific to that; but it could be a good starting point for others!