1. 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

Discussion in 'XenForo Questions and Support' started by Andy.N, Apr 14, 2011.

  1. Andy.N

    Andy.N Well-Known Member

    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
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
  3. Luke F

    Luke F Well-Known Member

    It's in the register_form template
     
    Young and Brogan like this.
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Ah, nice one DI.
    I hadn't considered it would be in a template, which makes it a simple change.
     
  5. Andy.N

    Andy.N Well-Known Member

    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>
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    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>
     
    maszd and Andy.N like this.
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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
     
  8. Andy.N

    Andy.N Well-Known Member

    Thanks Bro
     
  9. Andy.N

    Andy.N Well-Known Member

    You got ninja'd again by bro ;)
     
  10. qak01ok

    qak01ok New Member

    What would the code be if you wanted to add "Couple" to the list of options? Would this require anything special?
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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. madshark

    madshark Member

    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 likes this.
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yep. Just remove it from the template code posted above.
     
    RobinHood, erich37 and madshark like this.
  14. madshark

    madshark Member

    Thanks Jake :)
     
  15. erich37

    erich37 Well-Known Member

    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
     
  16. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
     
    maszd and erich37 like this.
  17. erich37

    erich37 Well-Known Member

    thanks a lot Jake ! (y)
     

Share This Page