I've made a small change to the report user_bulk_download.php in /var/www/html/moodle/admin/user to add the field lastaccess so I can run an extract to MailChimp that includes the user's last access date.
The extract report works but lastaccess is stored in UnixTime format and I need it in DD/MM/YYYY format for Mailchimp.
I know that I need to do something like this:
DATE_FORMAT(FROM_UNIXTIME(`lastaccess`),'%d/%m/%Y') AS lastaccess
to reformat the lastaccess date format, but I'm unsure where to put this in the code:
The code snippet below starts at line 42 in user_bulk_download.php
if ($dataformat) {
$fields = array('id' => 'id',
'username' => 'username',
'email' => 'email',
'firstname' => 'firstname',
'lastname' => 'lastname',
'city' => 'city',
'country' => 'country',
'lastaccess' => 'lastaccess');
if ($extrafields = $DB->get_records('user_info_field')) {
foreach ($extrafields as $n => $field) {
$fields['profile_field_'.$field->shortname] = $field->shortname;
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
}
}
Can someone please point me in the right direction?
thanks