• Resolved nathaniel45

    (@nathaniel45)


    I hope this is something can be down. I want to change the predefined field gender from a radio to drop down select. I was hopping not to have 2 metakeys with the same purpose. Also, I’m needing to add another option “prefer not to say” to it and it would look better to me as a select box then a radio.

    • This topic was modified 2 years, 9 months ago by nathaniel45.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter nathaniel45

    (@nathaniel45)

    I used to change the default type setting. Please let me know if I should not do this and why.

    add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
    function my_predefined_fields( $predefined_fields ) {
        if (is_array($predefined_fields['gender'])){
            $predefined_fields['gender']['type'] = 'select';
        }
        return $predefined_fields;
    }
    • This reply was modified 2 years, 9 months ago by nathaniel45.
    Plugin Support mansurahamed

    (@mansurahamed)

    Hi @nathaniel45,

    It’s not possible to change default predefined field type, different field types saves data in different format. You can create a custom dropdown field for gender field if you want to use the dropdown instead. That will work exactly like the predefined gender field and you will be able to use that custom field in member directory filter too.

    Thanks.

    Thread Starter nathaniel45

    (@nathaniel45)

    The code I posted did change the field but what would break? What do you use the gender for in the UM code? I looked and I can’t find it anywhere but the predefined fields that are set in the class-builtin.php file.

    • This reply was modified 2 years, 9 months ago by nathaniel45.
    Plugin Support Aswin Giri

    (@aswingiri)

    Hello @nathaniel45

    This is fine. You can use it this way. You can also add a placeholder since select fields have a placeholder by default.

    add_filter( 'um_predefined_fields_hook', 'my_predefined_fields', 10, 1 );
    function my_predefined_fields( $predefined_fields ) {
        if (is_array($predefined_fields['gender'])){
            $predefined_fields['gender']['type'] = 'select';
            $predefined_fields['gender']['placeholder'] = 'Choose Gender';
            $predefined_fields['gender']['options'] = array( __('Male','ultimate-member'), __('Female','ultimate-member'),__('Prefer not to say','ultimate-member') );
        }
        return $predefined_fields;
    }
    • This reply was modified 2 years, 9 months ago by Aswin Giri.
    Thread Starter nathaniel45

    (@nathaniel45)

    Good to know I can do it this way.

    thanks!

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Thanks for letting us know.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘change predefined field from radio to dropdown’ is closed to new replies.