Ok, I have had a look and this is what I have done to try and replicate the hack...
This line no longer is in user/view.php:
print_row(get_string("email").":", obfuscate_mailto($user->email, '', $user->emailstop)."$emailswitch");
In version 2.0 this code is used:
if ($currentuser
or $user->maildisplay == 1 //allow everyone to see email address
or ($user->maildisplay == 2 && is_enrolled($coursecontext, $USER)) //fellow course members can see email. Already know $user is enrolled
or has_capability('moodle/course:useremail', $coursecontext)) {
print_row(get_string("email").":", obfuscate_mailto($user->email, ''));
}
So what I have done is commented out two lines as follows:
if ($currentuser
//or $user->maildisplay == 1 //allow everyone to see email address
//or ($user->maildisplay == 2 && is_enrolled($coursecontext, $USER)) //fellow course members can see email. Already know $user is enrolled
or has_capability('moodle/course:useremail', $coursecontext)) {
print_row(get_string("email").":", obfuscate_mailto($user->email, ''));
}
I think this means that even if the learner sets to allow everyone or course members to see their email, it will still not display except to admins (that is how it works for me).
I also found I needed to do a similar hack in user/profile.php. The original code there is:
if ($currentuser
or $user->maildisplay == 1
or has_capability('moodle/course:useremail', $context)
or ($user->maildisplay == 2 and enrol_sharing_course($user, $USER)) ){
print_row(get_string("email").":", obfuscate_mailto($user->email, ''));
}
I changed it to:
if ($currentuser
// or $user->maildisplay == 1
or has_capability('moodle/course:useremail', $context)
//or ($user->maildisplay == 2 and enrol_sharing_course($user, $USER))
){
print_row(get_string("email").":", obfuscate_mailto($user->email, ''));
}
This seems to stop the email address from showing on the 'view profile' page to anyone except admins.
Lastly I changed the file user/editlib.php from:
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2);
to:
$choices = array();
$choices['0'] = get_string('emaildisplayno');
//$choices['1'] = get_string('emaildisplayyes');
//$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 0);
Now learners will only be able to see the setting of 'hide my email address from everyone' when editing their profile.
So changing those three files seems to solve my problem of hiding email addresses from other learners. Can anyone else confirm this has worked for them, or something better that does this?
Thanks