Displaying All Field Options in the Member Directory Inlcuding Empty Fields

The provided code snippet in this document ensures that all options for select dropdown fields are visible in the Member Directory, even if they currently have no users associated with them. This enhancement improves the user experience by providing comprehensive filtering options.

By default, when using the search filter in the Member Directory, empty fields are not shown in the search filter options. They only appear when a user has filled in a field.

For example, if you have selected the "age" field from the Admin Filtering in wp-admin > Ultimate Member > Member Directory > Edit a Member Directory > Search options, the filter option for "age" may not be showing on the front end of the Member Directory page because no user has filled out this field, meaning the field is currently empty. To display empty fields, you can use the code snippet provided below:

Note: You can add the code snippet to your theme's functions.php file or use the Code Snippets plugin.