Last updated: 2020-06-12
Works with CiviCRM 5.0 or higher.
Recording contacts' gender in a database in an inclusive way can be tricky. On one hand, you don't want to put people in a box. The ideal input on a form would be a free-text field like: My gender is: _________. On the other hand, you want your data to be searchable and sortable, and free-text input from users is not good for this. This extension gives you the best of both.
This extension allows free input on both front-end and back-end forms.
Behind the scenes, user input will be normalized if it matches an available gender option. So input like "m" or "male" will automatically select the "Male" option, "f" or "fem" will select "Female", and so on. This works regardless of how many options you have created, or your site's language. If input doesn't match an available option, it will be preserved as-is and displayed verbatim on CiviCRM view & search screens.
Once you install this extension you may want to revisit Administer > Customize Data & Screens > Dropdown Options > Gender. You'll notice that there is now an "Other" option, which is used internally by this extension. Consider adding some more options that users are likely to enter, this will help your data be as structured as possible by giving this extension more options to match to. Here are some guidelines for gender options.
How it Works
This extension creates a hidden custom field to store user's input for gender. Whatever they type will be stored in that field, and it will be used for display if it doesn't match an existing option. This extension updates most screens in CiviCRM to display gender appropriately. It also augments the CiviCRM API to accept any string for the field "gender_id", and to output a processed value as the "gender" field. This allows you to take advantage of this extension's functionality in your own applications via ordinary api calls.