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

Change default gender in registration page

Andy.N

Well-known member
#1
Currently, it's set to "Unspecified"
Since my site's audience is predominantly male, I like to have this set to Male and let people change in the registration page if they like.

How can I do it? I can't find anything in ACP
 

Brogan

XenForo moderator
Staff member
#2
It's not an option you can specify in the ACP.

You will need to edit one of the php files, I'll see if I can find which one.
 

Andy.N

Well-known member
#5
Hum, I look at that block in the template and can't make out anything that Unspecified is preselected. What do I need to change?
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>
 

Brogan

XenForo moderator
Staff member
#6
Move the ! from unspecified to male - !{$fields.gender}

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>
 

Jake Bunce

XenForo moderator
Staff member
#7
Admin CP -> Appearance -> Templates -> register_form

Replace this:

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>
with this:

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>
				<li><label for="ctrl_gender_"><input type="radio" name="gender" value="" id="ctrl_gender_" /> ({xen:phrase unspecified})</label></li>
			</ul>
		</dd>
	</dl>
I removed xen:checked from the unspecified option and changed the xen:checked condition for the male option.

edit - brogan! :p
 

Jake Bunce

XenForo moderator
Staff member
#11
What would the code be if you wanted to add "Couple" to the list of options? Would this require anything special?
There is no quick and easy way to implement that. See this thread:

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

I don't recommend trying to implement these changes. You should wait for 1.1 which will have profile fields. Then you can simply create a new field for marital status:

http://xenforo.com/community/threads/development-update-may-2011.16084/
 
#12
Can I remove the Unspecified option from the list without side effects? I gave it a test run doesn't seem to have any issues and technically i'd jus tbe removing just a checkbox line. But I'd like to be doubly sure :) I just want people to either select male or female.
 

erich37

Well-known member
#15
I only have "male" and "female" radio-buttons showing at my Register-form, because I do not want to have the "unspecified gender" showing up.
The radio-button for the gender "male" is selected by default, which is fine for me.


However, a few members who are registering are still showing the "unspecified gender" (questionmark) Avatar.

It is a bit confusing, when I do have only 2 redio-buttons (male / female) at my Register-Form........ how can it be that some members have an "unspecified gender"-Avatar ?


This is the code I am using at the "Register_form"-template:
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>
 
            </ul>
        </dd>
    </dl>

Is there something wrong in my code ?
I am on XF-version 1.1.1
 

Jake Bunce

XenForo moderator
Staff member
#16
For xen:checked for the male field you should use:

Code:
{xen:checked "{$fields.gender} == 'male' OR !{$fields.gender}"}
But this is still only superficial. It may still be possible for users to register without a gender. An addon is needed to enforce the requirement.