Not able to hide email addresses of students from each other. Please Help

Not able to hide email addresses of students from each other. Please Help

by smj jms -
Number of replies: 36

Hello:

I am not able to hide the email addresses of the students enrolled into a course from each other.

I went under Users->Permissions->User policies

and selected all the fields under "Hide user fields"

and still the students are able to see each other's email addresses when they click on their profiles.

We have a policy that we dont give out personal information. Please help, how can I get this to work?

Please help as soon as possibe

Thanks

Average of ratings: Useful (1)
In reply to smj jms

Re: Not able to hide email addresses of students from each other. Please Help

by Sandra King -
I hide student email addresses from everyone within the edit user profile page.

Here are the options that I choose between:
Email display: -Hide my email address from everyone or
-Allow everyone to see my email address or
-Allow only other course members to see my email address
Email activated: -This email address is enabled or
-This email address is disabled
Email format: -Plain text format or
-Pretty HTML format

This allows the system to send emails to the user, without their email address being public.

Regards,
Sandra King
In reply to Sandra King

Re: Not able to hide email addresses of students from each other. Please Help

by Howard Liverance -
Dear Sandra, this is great, but how do we set as a default for all students to hide email addresses and/or prohibit students from changing this setting on their profile. If we want to enforce email security this is the only possibility. We don't want students coming back to us saying they "didn't know" about that setting. So far I am unable to find anyway in Moodle 1.8 to set the default to "hide email from everyone", and then make it so students cannot manually change this setting. Anyone have a solution?
In reply to Howard Liverance

Re: Not able to hide email addresses of students from each other. Please Help

by J Handler -

I am looking in the code how I can set this to be the only option for this field.  in Version 1.5.4 it was in user\edit.html   anyone know where this option is set in the code in version 1.8.2   We like to make this the default and not allow students to ever make changes as well

Thanks,

Joel

In reply to J Handler

Re: Not able to hide email addresses of students from each other. Please Help

by J Handler -

Found it,

In user\editlib.php comment out the following two lines


    //$choices['1'] = get_string('emaildisplayyes');
    //$choices['2'] = get_string('emaildisplaycourse');

They no longer can change their option

In reply to J Handler

Re: Not able to hide email addresses of students from each other. Please Help

by Rosie Cardiff -

I would like to make the default for new users that their e-mail addresses are hidden from everyone but that they still have the option of displaying their email address to other course users if they want to. Will this fix above work or does it prevent users from changing the email options themselves?

Also, if I implement the fix above, will this also mean that the admin user can't see everyone's email addresses?

Thanks

In reply to Rosie Cardiff

Re: Not able to hide email addresses of students from each other. Please Help

by Charlotte Smith -

Does anyone know the answer to this as I have the same problem. I just want to hide users email addresses from each other as default for security reasons, I'm not bothered about whether they can then make it visible themselves or not. The fix above (user/editlib.php) would be fine for my needs but I'm using Moodle 1.9 and this file doesn't seem to be in this folder anymore.

Can anyone help me locate this file in Moodle 1.9 or have any other ways to do this? 

In reply to Charlotte Smith

Re: Not able to hide email addresses of students from each other. Please Help

by Ken Wilson -

Charlotte

It might be worthwhile getting a fresh download to compare with, as I can see the file in moodle/user/editlib.php. Lines 87-92 are the relevant ones and need changing as shown in red:

    $choices = array();
    $choices['0'] = get_string('emaildisplayno');
    //$choices['1'] = get_string('emaildisplayyes'); //removed option
    //$choices['2'] = get_string('emaildisplaycourse'); //removed option
    $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
    $mform->setDefault('maildisplay', 0); //changed from default of 2

There are several other options in that section which control the choices available in the drop down boxes, e.g adding a comment symbol before the line

$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);

removes the display of the box of choices altogether. There must be a more elegant way of doing this thoughtful, but see if this works for you. If you do change things, add your name or initials as a comment above the line and note it down on paper so that you know where you have changed things next time you upgrade.

Hope this helps!

Ken

Average of ratings: Useful (1)
In reply to Ken Wilson

Re: Not able to hide email addresses of students from each other. Please Help

by Charlotte Smith -
Thanks Ken, you're a lifesaver. It looks like my files weren't complete...
In reply to Ken Wilson

Re: Not able to hide email addresses of students from each other. Please Help

by Samuel Lundqvist -
We are using the Shibboleth authorization filter for our users. This means that users do not get to the user-fields page when they log in to Moodle for the first time. Hence, the nice workaround you propose does not seem to help us. It is possible to update the database with something like
update mdl_user SET maildisplay="0"
in a cron job, but I don't like having to manually access the database. There should be another way to achieve this. Any proposals?

Regards,
Samuel


In reply to Samuel Lundqvist

Re: Not able to hide email addresses of students from each other. Please Help

by Pete MacKichan -
The simplest way is to use your DBMS to run the update. I just ran the update in phpMyAdmin and it worked fine.

I think 0 is an int not a char so you need
UPDATE mdl_user SET maildisplay=0

HTH

Pete
In reply to Howard Liverance

Re: Not able to hide email addresses of students from each other. Please Help

by ben reynolds -
In 1.9, when you upload users, one of the fields is maildisplay. See http://docs.moodle.org/en/Upload_users#Flat_file_format You can set this to "Hide my email address from everyone."

Also in 1.9 Administration>Users>Manual Accounts>Locked Fields set Email Address to "Unlocked if Empty." Once the field is filled, it is not editable. You want unlocked if empty in case you upload a user without an email address.

The e-address is Moodle's unique identifier, so a user without an email address is directed straight to "edit profile" unpon login and must be able to add an e-add.
Otherwise, the e-add is locked.

Manage Authentication has similar fields.
Average of ratings: Useful (1)
In reply to ben reynolds

Re: Not able to hide email addresses of students from each other. Please Help

by ben reynolds -
This is just to say that we use a flat file to upload users, per my first paragraph in post of April 24. We set the field to "Hide my email address..." and that works for every student who doesn't want their e-add visible.

If they do, they can change it, but they all start out not visible. Our experience is that not many students make their e-add visible.
In reply to smj jms

Re: Not able to hide email addresses of students from each other. Please Help

by Manish Verma -
I have tested the following in 1.9:

In user/view.php look for the following line:

print_row(get_string("email").":", obfuscate_mailto($user->email, '', $user->emailstop)."$emailswitch");

Just replace it with this:

if (isteacher($course->id) or isadmin() or $currentuser) {
print_row(get_string("email").":", obfuscate_mailto($user->email, '', $user->emailstop)."$emailswitch");
}
Average of ratings: Useful (1)
In reply to Manish Verma

Re: Not able to hide email addresses of students from each other. Please Help

by John Fitchett -

thank you! this worked for me!

Should be a setting in Moodle, rather than a hack though!

In reply to Manish Verma

Re: Not able to hide email addresses of students from each other. Please Help

by Kris C -
Awesome! Works greatapprove
In reply to Manish Verma

Re: Not able to hide email addresses of students from each other. Please Help

by james aco -

hi

i edit the view.php file as your instruction but its doesn't work for me

i'm using 1.95 ver

i attached the file

will you check it and help me with my mistake?

thank you

In reply to james aco

תשובה ל: Re: Not able to hide email addresses of students from each other. Please Help

by james aco -

hi

someone can help please?

thank you

In reply to Manish Verma

Re: Not able to hide email addresses of students from each other. Please Help

by John Fitchett -

Ho wcan we get this to work for Moodle 2.0?

 

 I need to hide all users email addresses.

In reply to John Fitchett

Ang: Re: Not able to hide email addresses of students from each other. Please Help

by Bente Olsen -
Picture of Testers Picture of Translators

Users can hide their email addresses from everyone in their profile settings. You can also update all user profiles by uploading a csv file with the new settings. See docs.moodle.org about Upload users

In reply to Bente Olsen

Re: Ang: Re: Not able to hide email addresses of students from each other. Please Help

by John Fitchett -

Hi Bente

Yes, this allows users to choose to hide their email addresses, but it doesn't do it by default.

How can it be made default for all users that:

1) Their email addresses are hidden?

2) They can't 'unhide' them?

In reply to John Fitchett

Ang: Re: Ang: Re: Not able to hide email addresses of students from each other. Please Help

by Bente Olsen -
Picture of Testers Picture of Translators

Moodle do not have this feature, if you want email addresses always to be hidden you have to modify the code. You might be lucky though that there is a plugin available you can use.

In reply to Manish Verma

Re: Not able to hide email addresses of students from each other. Please Help

by John Fitchett -

This hack worked perfectly in Moodle 1.9

How can it be changed to work in Moodle 2.0+ ?

In reply to Manish Verma

Re: Not able to hide email addresses of students from each other. Please Help

by John Fitchett -

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

In reply to smj jms

Re: Not able to hide email addresses of students from each other. Please Help

by Noveck Gowandan -
I was able to accomplish this with the database update. [Moodle Version 1.9.7]

My students are authenticated via LDAP, and I didnt want my Lecturer (who are manual accounts) email details hidden so I ran the following:


update mdl_user
set maildisplay=0
where auth='ldap'

Since my Accounts are created with the ldap plugin, I didnt need to do a php interface hack to force the setting to 'Hidden' from the account creation page. Instead, I opted to make the Default 'Hidden' - it was currently on 'Email visible for users who share a course'.



update table mdl_user
alter column maildisplay
set default 0; -- note the previous default was 2

Now the possibility exists that students can still change this setting back to visible, so a nightly cron script can be run to change all back to hidden. This has a minimal overhead as the update takes <1sec to execute.

I still have to monitor the accounts to ensure that newly created ones are hidden. I will update this post within the next week or so to confirm. The solution to this will be the cronscript mentioned above.


Cheers,
-n
Average of ratings: Useful (1)
In reply to smj jms

Re: Not able to hide email addresses of students from each other. Please Help

by nency de -

I still confuse how to hide my email plz help me about it...

(Edited by Helen Foster to remove spam link - original submission Tuesday, 31 January 2012, 10:17 AM)

In reply to nency de

Re: Not able to hide email addresses of students from each other. Please Help

by Bente Olsen -
Picture of Testers Picture of Translators

Hi nency

You have already your email hidden here at moodle.org. Go to your profile settings page and have a look at the 'Email display' setting. You can use the same setting in Moodle 1.9

Just to clarify: I can give you the URL to modify your profile, I do not have permission to enter the page.

Bente

In reply to smj jms

Re: Not able to hide email addresses of students from each other. Please Help

by Bente Olsen -
Picture of Testers Picture of Translators

I have an open record in the tracker, MDL-29534, 'Use email address in reply can not be deactivated', that you might be interested to vote for. I do not know though, if this issue applies to users having their email hidden, so that their email is revealed when Moodle is sending out forum mails.

In reply to Bente Olsen

Re: Not able to hide email addresses of students from each other. Please Help

by Veronica Arena -

This is a very interesting discussion. I would like to get students' email addresses hidden, but also, when they participate on forums, and e-mails are sent to other members, they shouldn't be able to see each e-mail address. Any way how we can work this out in Moodle 2.2?

Veronica

In reply to smj jms

Re: Not able to hide email addresses of students from each other. Please Help

by Deleted user -
5.5 years later, using Moodle 2.1 and I'm still very interested in a neat outcome for this question. I'd like to avoid hacking core (I need to update to 2.3+ soon) but I also need to be able to hide student emails and surnames, and deny the user any option to display these details, for a particularly security-conscious customer. Fields such as Surname fall within the required fields in the General category of the profile editor page, but there appears to be no way to hide it. Some moodle magic knowledge would be much appreciated
In reply to Deleted user

Re: Not able to hide email addresses of students from each other. Please Help

by Deleted user -
Partial solution: I was able to hide surnames by adding the following command to the Moodle config.php file: $CFG->forcelastname = ' ';
In reply to Deleted user

Re: Not able to hide email addresses of students from each other. Please Help

by Sarah Jane -

Has anyone an answer to this please. I am using 2.2.7 and would like to have the emails hidden by default.

Appreciate any help please.

Sarah x

In reply to Sarah Jane

Re: Not able to hide email addresses of students from each other. Please Help

by Vladimir ZH -

I also want to hide emails . how to make it hidden default?

In reply to Vladimir ZH

Re: Not able to hide email addresses of students from each other. Please Help

by Sakshi Goel -

Hello Sarah and Vladimir
Set email display to "Hide my email address from everyone" in the user profile setting page.

In reply to Sakshi Goel

Re: Not able to hide email addresses of students from each other. Please Help

by Nicolas Connault -

This only hide a single user's email address. 

Since 2005, dozens (hundreds?) of Moodle administrators want to have this setting default to "Hide from everyone" when a new user account is created (manually, through email self-registration, or otherwise). (See MDL-2802 for earliest record)

It's now 2013 and I'm sorry to say but this is still not possible without hacking the core. 

If you want the ability to set default values for this and other user settings, please vote for MDL-37812

In reply to Nicolas Connault

Re: Not able to hide email addresses of students from each other. Please Help

by Derek Chirnside -

I doubt if there is any intention from HQ to work on this.  https://tracker.moodle.org/browse/MDL-2802 has been on the books for seven years, and only three votes.  The other related tracker items are not linked in to this request either, and no-one has updated it to recent versions or collated all the forum posts;  ie the bug is not getting much love.

And https://tracker.moodle.org/browse/MDL-37812, while I have voted for it and agree with it, it is not the most friendly title, and no-one seems to be caring for this bug either, with comments, patches etc.

Part of the problem could be I suspect that many would see this what you regard as a problem to be a feature.  Why are you trying to hide addresses from people?  Where is the trust, where is the collaboration? 

In this, we may be left with maintaining a hack.  In which case, someone who knows can update the tracker item for each new version of Moodle with the instructions to fix it.  I know.  Painful.

-Derek

In reply to Derek Chirnside

Re: Not able to hide email addresses of students from each other. Please Help

by Tim Morrissey -

Nicely summed up, Derek. It is indeed a painful and, most likely, a hopeless cause, and I fear Moodleism will triumph over common sense. Thanks for your post.