@melchi2
This code snippet will accept all additional gender choices
you have added to your registration form gender field
and make them searchable in the membership page.
Genders without search hits are removed from the membership page dropdown by UM.
add_filter( 'um_predefined_fields_hook', 'my_um_gender_addition', 10, 1 );
function my_um_gender_addition( $predefined_fields ) {
$forms = get_posts( array( 'post_type' => 'um_form', 'post_status' => array( 'publish' )));
foreach( $forms as $form ) {
$field_data = get_post_meta( $form->ID, '_um_custom_fields', true );
if( isset( $field_data['gender'] ) && count( $field_data['gender']['options'] ) > 2 ) {
$predefined_fields['gender']['options'] = $field_data['gender']['options'];
}
}
return $predefined_fields;
}
Add the code snippet to your child theme functions.php file
or add to the “Code Snippets” plugin.
https://www.ads-software.com/plugins/code-snippets/