A member directory becomes much more powerful when visitors can do more than just scroll through a list of names. The ability to filter by location helps members find others nearby. Whether you’re running a professional association, or a local club, location-based search is a key way to make your directory truly useful.
This recipe shows you how to add a filter that allows visitors to search and sort members based on their proximity to a chosen location, directly on the Membership Map included in the Member Directory and Profile Pages Add On.
Table of contents
Understanding How the Code Filters by Distance
This recipe works by calculating the actual distance between two points on a map using latitude and longitude. When someone searches for members “within 10 miles,” the code measures that distance and only shows results that fall inside the chosen radius. If the unit is set to kilometers, the code recipe will also handle the conversion.
The key idea: filtering isn’t based on text like city names—it’s based on real geographic distance, which makes the results far more accurate.
About the Code Recipe
The recipe enables a distance-based search on your Membership Map. With this in place, visitors can search for members nearby or within a specific radius.
To use this recipe, your setup will need:
- Member addresses that are geocoded (so they can be mapped).
- A configured map through the Member Directory Add On.
Once configured, site visitors will be able to view members on the map and filter them by distance.
This filtration method will allow you to sort members based on their location. This is great for membership sites that want their members to find each other. For example, franchise chains, club memberships, or even groups.
The Code Recipe
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.


