• Resolved nctbrtc

    (@nctbrtc)


    I’m trying to customize a dropdown filter for my site.
    I need to make all the dropdown filter choices be listed even there are no matching users.

    To specify, I’m adding a profession selector, users need to pick a profession, I have a large list for this dropdown, it shows up when users want to update his/her profile but on the member’s page, you only see professions that only if someone picked it. I want to show the whole list even nobody under.

    I wish there was an easy way to do it

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @nctbrtc

    You can try this code snippet. It’s created for the Country field. You just need to change the meta key to your field key and then add the Professions in the array. See how I add the Apple in the Country field options.

    add_filter("um_member_directory_filter_select_options", function( $opts, $values, $atts){
        
        if( isset( $atts['metakey'] ) && $atts['metakey'] == 'country' ){
         
            $new_arr = [
                'AAAA' => 'Apple',
            ];
    
            $opts = array_merge( $opts, $new_arr );
            
        }
    
        return $opts;
     },10, 3);

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @nctbrtc

    …Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to show all filter choice even there is no memebers?’ is closed to new replies.