• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Removing Gender?

#1
This is probably a slightly odd question, but how easy would it be to remove gender as an option to fill out? I'm assuming this would require some tweaking with the avatars.
 

Jake Bunce

XenForo moderator
Staff member
#2
You can remove it from the templates:

Admin CP -> Appearance -> Templates -> register_form

Remove this code:

Code:
	<dl class="ctrlUnit">
		<dt>{xen:phrase gender}:</dt>
		<dd>
			<ul>
				<li><label for="ctrl_gender_male"><input type="radio" name="gender" value="male" id="ctrl_gender_male" {xen:checked "{$fields.gender} == 'male'"} /> {xen:phrase male}</label></li>
				<li><label for="ctrl_gender_female"><input type="radio" name="gender" value="female" id="ctrl_gender_female" {xen:checked "{$fields.gender} == 'female'"} /> {xen:phrase female}</label></li>
				<li><label for="ctrl_gender_"><input type="radio" name="gender" value="" id="ctrl_gender_" {xen:checked "!{$fields.gender}"} /> ({xen:phrase unspecified})</label></li>
			</ul>
		</dd>
	</dl>
A similar edit must be made to account_personal_details.

Removing this field will result in everyone having an "unspecified" gender.
 
#3
You can remove it from the templates:

Admin CP -> Appearance -> Templates -> register_form

Remove this code:

Code:
<dl class="ctrlUnit">
<dt>{xen:phrase gender}:</dt>
<dd>
<ul>
<li><label for="ctrl_gender_male"><input type="radio" name="gender" value="male" id="ctrl_gender_male" {xen:checked "{$fields.gender} == 'male'"} /> {xen:phrase male}</label></li>
<li><label for="ctrl_gender_female"><input type="radio" name="gender" value="female" id="ctrl_gender_female" {xen:checked "{$fields.gender} == 'female'"} /> {xen:phrase female}</label></li>
<li><label for="ctrl_gender_"><input type="radio" name="gender" value="" id="ctrl_gender_" {xen:checked "!{$fields.gender}"} /> ({xen:phrase unspecified})</label></li>
</ul>
</dd>
</dl>
A similar edit must be made to account_personal_details.

Removing this field will result in everyone having an "unspecified" gender.
Wow, thanks. Now all I have to do is figure out how I'm going to afford a license.
 
#7
This is probably a slightly odd question, but how easy would it be to remove gender as an option to fill out? I'm assuming this would require some tweaking with the avatars.
On a slightly odder note, is it possible to ADD selections to the gender possibilities? I'm working on a project that validates the existence of genders outside of the accepted male/female dichotomy.

If it is possible, how's it done? I'd rather have more selections rather than just "unspecified."
 

James

Well-known member
#8
On a slightly odder note, is it possible to ADD selections to the gender possibilities? I'm working on a project that validates the existence of genders outside of the accepted male/female dichotomy.

If it is possible, how's it done? I'd rather have more selections rather than just "unspecified."
You'd have to edit/extend XenForo_DataWriter_User::_getFields() on lines 57 and 58 to allow more values:
PHP:
'gender'
=> array('type' => self::TYPE_STRING, 'default' => '', 'allowedValues' => array('male', 'female', '', 'hermaphrodite', 'etc')),
Then you'd have to edit the gender template to add the extra values.
 
#9
Will this cause issues with default avatars for male and female? What will Xenforo do when it looks for something other than male/female?
 
#11
I tried to add more gender options (edited user.php in line 58 as well as the template), but when I try to put something other then "male"/"female"/"" into the field, i get the following message:

Mysqli statement execute error : Data truncated for column 'gender' at row 1
  1. Zend_Db_Statement_Mysqli->_execute() in Zend/Db/Statement.php at line 297
  2. Zend_Db_Statement->execute() in Zend/Db/Adapter/Abstract.php at line 479
  3. Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 632
  4. Zend_Db_Adapter_Abstract->update() in XenForo/DataWriter.php at line 1607
  5. XenForo_DataWriter->_update() in XenForo/DataWriter.php at line 1576
  6. XenForo_DataWriter->_save() in XenForo/DataWriter.php at line 1381
  7. XenForo_DataWriter->save() in XenForo/ControllerPublic/Account.php at line 285
  8. XenForo_ControllerPublic_Account->actionPersonalDetailsSave() in XenForo/FrontController.php at line 310
  9. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  10. XenForo_FrontController->run() in /usr/www/users/veganiu/vegani/f/index.php at line 13
Any ideas?^^
 

Jake Bunce

XenForo moderator
Staff member
#13
I replied to JC's private message, but I am posting it here too:

On a slightly odder note, is it possible to ADD selections to the gender possibilities?
That requires some doing. See this post:

http://xenforo.com/community/threads/can-i-add-a-gender-option-i-e-couple.7276/#post-102746

Search the templates for "gender". I find these templates:

Admin CP -> Appearance -> Templates
> account_personal_details
> member_view
> message_user_info
> register_form


Search for "female" in the files and you will find some code you need to change. I found these:

library/XenForo/DataWriter/User.php
library/XenForo/Template/Helper/Core.php
library/XenForo/ControllerPublic/Register.php
library/XenForo/Install/Data/MySql.php

And you will need to change the definition of the xf_user.gender field in the database.
You might consider just creating a profile field for this:

Admin CP -> Users -> Custom User Fields
 

RoldanLT

Well-known member
#14
You can remove it from the templates:

Admin CP -> Appearance -> Templates -> register_form

Remove this code:

Code:
    <dl class="ctrlUnit">
        <dt>{xen:phrase gender}:</dt>
        <dd>
            <ul>
                <li><label for="ctrl_gender_male"><input type="radio" name="gender" value="male" id="ctrl_gender_male" {xen:checked "{$fields.gender} == 'male'"} /> {xen:phrase male}</label></li>
                <li><label for="ctrl_gender_female"><input type="radio" name="gender" value="female" id="ctrl_gender_female" {xen:checked "{$fields.gender} == 'female'"} /> {xen:phrase female}</label></li>
                <li><label for="ctrl_gender_"><input type="radio" name="gender" value="" id="ctrl_gender_" {xen:checked "!{$fields.gender}"} /> ({xen:phrase unspecified})</label></li>
            </ul>
        </dd>
    </dl>
A similar edit must be made to account_personal_details.

Removing this field will result in everyone having an "unspecified" gender.
How about removing only the unspecified button, and defaults the selection to male?
 

Jake Bunce

XenForo moderator
Staff member
#15
@RoldanLT

Code:
	<dl class="ctrlUnit">
		<dt>{xen:phrase gender}:</dt>
		<dd>
			<ul>
				<li><label for="ctrl_gender_male"><input type="radio" name="gender" value="male" id="ctrl_gender_male" {xen:checked "{$fields.gender} == 'male' OR !{$fields.gender}"} /> {xen:phrase male}</label></li>
				<li><label for="ctrl_gender_female"><input type="radio" name="gender" value="female" id="ctrl_gender_female" {xen:checked "{$fields.gender} == 'female'"} /> {xen:phrase female}</label></li>
			</ul>
		</dd>
	</dl>
 

RoldanLT

Well-known member
#17
XF 1.4 has different template:
Code:
<dl class="ctrlUnit">
        <dt>{xen:phrase gender}:</dt>
        <dd>
            <ul>
                <li><label><input type="radio" name="{$fieldMap.gender}" value="male" {xen:checked "{$fields.gender} == 'male'"} /> {xen:phrase male}</label></li>
                <li><label><input type="radio" name="{$fieldMap.gender}" value="female" {xen:checked "{$fields.gender} == 'female'"} /> {xen:phrase female}</label></li>
                <li><label><input type="radio" name="{$fieldMap.gender}" value="" {xen:checked "!{$fields.gender}"} /> ({xen:phrase unspecified})</label></li>
            </ul>
        </dd>
    </dl>