Where is option for gender changing?
I want to make possible only for admin to change members gender..
As far as I'm aware there isnt.
You'll probably need to request it as a mod.
There must be some code which controls this...
There isnt a setting to enable/disable it because if smf had a setting for every little option, it would become very bloated.
It would be best as a mod because very few smf sites use the 'gender information'.
You'd probably have to modify the profile.template.php to not show the profile gender field unless your an admin.
I know that, but i cant find what to change, i cant see that code...
around like 1412 of profile.template.php
<select name="gender" size="1">
<option value="0"></option>
<option value="1"', ($context['member']['gender']['name'] == 'm' ? ' selected="selected"' : ''), '>', $txt[238], '</option>
<option value="2"', ($context['member']['gender']['name'] == 'f' ? ' selected="selected"' : ''), '>', $txt[239], '</option>
</select>
And to change with what to allow only admins to change it?
Ok, I've just tested this on a clean install.
The gender options only show up if the user browsing is an admin OR if the user doesnt have a gender already set. (once they set a gender it will disappear)
(you will need to perform this modification on any themes which have custom Profile.template.php's
FIND (1409 - 1420 in clean install) in Profile.template.php
<tr>
<td width="40%"><b>', $txt[231], ': </b></td>
<td>
<select name="gender" size="1">
<option value="0"></option>
<option value="1"', ($context['member']['gender']['name'] == 'm' ? ' selected="selected"' : ''), '>', $txt[238], '</option>
<option value="2"', ($context['member']['gender']['name'] == 'f' ? ' selected="selected"' : ''), '>', $txt[239], '</option>
</select>
</td>
</tr><tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>';
REPLACE WITH
';
// SHOW GENDER ONLY IF NOT SET OR USER VIEWING PROFILE IS ADMIN
if($context['user']['is_admin'] || empty($context['member']['gender']['name'])) {
echo ' <tr>
<td width="40%"><b>', $txt[231], ': </b></td>
<td>
<select name="gender" size="1">
<option value="0"></option>
<option value="1"', ($context['member']['gender']['name'] == 'm' ? ' selected="selected"' : ''), '>', $txt[238], '</option>
<option value="2"', ($context['member']['gender']['name'] == 'f' ? ' selected="selected"' : ''), '>', $txt[239], '</option>
</select>
</td>
</tr>
';
}
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>';
Dont work...
All members can change...
In that code, change
if($context['user']['is_admin'] || empty($context['member']['gender']['name']))
to
if($context['user']['is_admin'])
if you ONLY want admins to add or change it....
or
if($context['user']['is_admin'] || $context['member']['gender']['name'] == '')
if you want members to set it but only admins can CHANGE it after...
Keep in mind, however, that somebody smart can use an extension for their browser to alter the post data and add in a gender field. You might want to look into a mod into Profile.php itself to protect from this.
Quote from: Kirby on August 13, 2007, 01:31:59 PM
You might want to look into a mod into Profile.php itself to protect from this.
I dont understand what you mean with this...
Here, look for (Profile.php):
'gender' => array(
'name' => empty($_POST['gender']) ? '' : ($_POST['gender'] == 2 ? 'f' : 'm')
),
Replace with:
'gender' => array(
'name' => ($context['user']['is_admin'] || empty($user_profile[$_REQUEST['userID']]['gender']) ? (empty($_POST['gender']) ? '' : ($_POST['gender'] == 2 ? 'f' : 'm')) : '')
),
This will give you an additional layer of security.