Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Aiheen aloitti: Absorb - heinäkuu 22, 2011, 05:53:31 IP

Otsikko: Hide Email addresses by default
Kirjoitti: Absorb - heinäkuu 22, 2011, 05:53:31 IP
Hi all,
I run 1.1.13 and was wondering if it is possible to make all email addresses hidden to all but Administrators.
Is there something I can also do that will also adjust all existing members profiles so that their email addresses will not be seen
Regards
Paul
Otsikko: Re: Hide Email addresses by default
Kirjoitti: shadow82x - heinäkuu 23, 2011, 11:15:58 IP
Try this - http://custom.simplemachines.org/mods/index.php?mod=371
Otsikko: Re: Hide Email addresses by default
Kirjoitti: Absorb - heinäkuu 25, 2011, 12:25:23 AP
Great mod, but I want to remove the ability for people to see the email or any contact info when they click on the Members button.

The only way I can see without a mod is going through each member 1 at a time and adjusting their profile with "Email not visible" - Big job with over 750 members
Otsikko: Re: Hide Email addresses by default
Kirjoitti: AK49BWL - heinäkuu 25, 2011, 04:49:21 AP
You could write a quick script in PHP to do the update job for you using the forum's SSI.. This is rough but should work:

<?php
include $_SERVER['DOCUMENT_ROOT'].'/path/to/forum/SSI.php'// takes care of connecting to mysql

if (!$context['user']['is_admin']) die('Only admins are allowed to run this script.'); // Protect yourself ;)

$query db_query("SELECT ID_MEMBER FROM {$db_prefix}members WHERE hideEmail = 0",__FILE__,__LINE__); // Get current members with un-hidden emails

$numrows mysql_numrows($query); // total found with un-hidden emails
$i=0;

while (
$row mysql_fetch_assoc($query)) {
  
$update db_query("UPDATE {$db_prefix}members SET hideEmail = 1 WHERE ID_MEMBER = '".$row['ID_MEMBER']."'",__FILE__,__LINE__); // Hide the emails!
  
if ($update)
    
$i++;
}

echo 
'A total of '.$i.' changes were made out of the '.$numrows.' found with un-hidden emails.';

?>


Hope this works (and that I'm actually allowed to post something like this...)! I ran it on my server and it worked as intended.