Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Aiheen aloitti: crawman - kesäkuu 02, 2011, 01:14:36 IP

Otsikko: hide email addresses by default
Kirjoitti: crawman - kesäkuu 02, 2011, 01:14:36 IP
Is there any way to hide email addresses in the profile by default in a 1.1.13 forum?

I've been reading and the only way I (without installing a mod) is to have each person hide their email in their profile (which is not really an option for this particular forum).

If a mod is the only way- can anyone recommend a mod?

Thanks in advance
Otsikko: Re: hide email addresses by default
Kirjoitti: Sir Osis of Liver - kesäkuu 02, 2011, 03:45:18 IP

This should do it.

In Profile.template.php

Find this:



// Only show the email address if it's not hidden.
if ($context['member']['email_public'])
echo '
<a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a>';
// ... Or if the one looking at the profile is an admin they can see it anyway.
elseif (!$context['member']['hide_email'])
echo '
<i><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></i>';
else
echo '
<i>', $txt[722], '</i>';




Change it to this:



/// Only show the email address to admins.
// if ($context['member']['email_public'])

if ($user_info['groups']['0'] == '1')
echo '
<a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a>';

// ... Or if the one looking at the profile is an admin they can see it anyway.
// elseif (!$context['member']['hide_email'])
// echo '
// <i><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></i>';
else
echo '
<i>', $txt[722], '</i>';




Only admins will see email addresses in profiles; all others will see 'hidden'.

Otsikko: Re: hide email addresses by default
Kirjoitti: crawman - kesäkuu 02, 2011, 03:59:13 IP
Thank You VERY much. I'll give it a spin!

Thanks again!
Otsikko: Re: hide email addresses by default
Kirjoitti: crawman - kesäkuu 03, 2011, 01:04:32 IP
I'm using a custom theme. Do I put it in display.template.php over the following code?
   



// Don't show the email address if they want it hidden.
if (empty($message['member']['hide_email']))
echo '
<a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';
Otsikko: Re: hide email addresses by default
Kirjoitti: Sir Osis of Liver - kesäkuu 03, 2011, 02:22:09 IP
Attach your Profile.template.php and Display.template.php, and I'll have a look.  Which theme are you using?

Otsikko: Re: hide email addresses by default
Kirjoitti: crawman - kesäkuu 03, 2011, 06:18:38 IP
Here is the Display.template.php from the custom theme that is running called "BisdakWorldClassic" and the Profile.template.php from the default theme.

Thanks again for your help!
Otsikko: Re: hide email addresses by default
Kirjoitti: Sir Osis of Liver - kesäkuu 03, 2011, 11:02:03 IP
Ok, it's actually two different things.  The code for Profile.template.php will hide all email addresses for all members in member profile - only admins can see them.  Display.template.php shows the email icon in the user post info panel, unless email is hidden by member.  The email address is displayed in the browser status bar when you mouseover the icon, and in the mail client when you click the icon, so you have to remove the email icon altogether.  Members can always pm each other, so it's not a problem.

If you want to eliminate the email icon altogether, in Display.template.php -

Find this:



// Don't show the email address if they want it hidden.
if (empty($message['member']['hide_email']))
echo '
<a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';




and delete it (or comment it out until you're sure).

If you want admins only to see the mail icon, change it to this:



/// Don't show the email icon except to admins.
if (empty($message['member']['hide_email']) && $user_info['groups']['0'] == '1')
echo '
<a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';

Otsikko: Re: hide email addresses by default
Kirjoitti: Aleksi "Lex" Kilpinen - kesäkuu 26, 2011, 03:33:09 AP
Hi crawman, any updates to this - do you still need assistance with this? :)