• Resolved melchi2

    (@melchi2)


    Hello, I wanted to know if there is a solution so that the choice of sex in the member search engine is not limited to men and women. I would like to include couple and transgender. Thank you for your help

    • This topic was modified 3 years, 1 month ago by melchi2.
Viewing 3 replies - 1 through 3 (of 3 total)
  • @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/

    Thread Starter melchi2

    (@melchi2)

    Hello @missveronicatv Thank you it works perfectly, I’m so happy, you are the light in my night.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @melchi2

    Thanks for letting us know how @missveronicatv’s solution resolves your issue.

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Choice Sex’ is closed to new replies.