Adding a Gender Field to Signup and User

George Morris Posted in Beginning Developers 9 years ago

Hi

I'm trying to add a gender field "other" to OSSN. I have found some files that need changing, but ultimately, I don't know how to change the appearance of the signup form and user forms so they show more than just male and female.

Thanks!

Replies
se Johannes Genberg Replied 6 years ago

I wasn't really sure what to do. Do I just need to add the code you provided? You mentioned something about creating a new component.

Indonesian Arsalan Shah Replied 6 years ago

This is a complete solution provided below , even it is a entire component you just need to place code in your ossn_com.php file of your component.

se Johannes Genberg Replied 6 years ago

Can you upload the component here? Half a solution is no good for me :)

us Eli Smith Replied 9 years ago

Hello, this was extremely useful. Do you know how one may add this third gender (along with a color like the other genders) to the stats on the Admin Dashboard?

Indonesian Arsalan Shah Replied 9 years ago

Hi, download the HelloWorld component and paste the contents of my below reply in ossn_com.php (components/HelloWorld/ossn_com.php)

us Jeremy Monroe Replied 9 years ago

Nevermind...Have to create the component first. lol Trying to work on too many things at once. Sorry about that.

us Jeremy Monroe Replied 9 years ago

Where is the file located? I seem to be overlooking it.

Indonesian Arsalan Shah Replied 9 years ago

Create new component and place following code in your ossn_com.php file

<?php
function new_gender_init() {
		ossn_add_hook("user", "default:fields", "new_gender");
}
function new_gender($hook, $type, $val, $params) {
		$toremove           = array(
				"gender"
		);
		$return             = ossn_remove_field_from_fields($toremove, $val);
		$fields["required"] = array(
				"radio" => array(
						array(
								"name" => "gender",
								"options" => array(
										"male" => ossn_print("male"),
										"female" => ossn_print("female"),
										"other" => "Other"
								)
						)
				)
		);
		return array_merge($return, $fields);
}
ossn_register_callback("ossn", "init", "new_gender_init");