How to Search Your BuddyPress Members by Location
Would you like to be able to look for and organize your BuddyPress members by where they are located? In the article below, I will demonstrate how to search your BuddyPress members by their location directly from your WordPress control panel, with the Users Insights plugin and its Geolocation module.
To get started you first have to make sure that you have installed and activated the Users Insights plugin on your BuddyPress website. Also, for this tutorial, we are going to need the BuddyPress and Geolocation modules of Users Insights activated. You can activate them from the Module Options section of the Users Insights plugin in your WordPress dashboard.
The Geolocation module, when activated, will automatically detect and store your BuddyPress member location every time they visit your website. This module detects and stores the following information: the city, region, and country where the member is located. The Geolocation module also adds a few filters into the Filters section of Users Insights that allows you to search and filter your members by using the members’ location data. This data is also available in the BuddyPress reports page.
Sorting the BuddyPress member list by location
The geolocation data that the Users Insights plugin detects and stores for your members will be then available in the Users Insights table. The table columns that contain this information are the City, Region, and Country. You can show/hide these fields from the user table by clicking on the “eye” icon. If you want to order your member list by the country they come from, you can do this by simply clicking on the title of the column “Country”. This will sort your buddypress and buddyboss members list in a ascending order by the name of the country.
If you click once more, the list of users will be sorted in a descending order.
Showing only members from a specific country
If you want to show a list off all the members from a specific country you can add a filter “Country is” or “Country contains” and type the name of the country. Here is an example of the list of all the members from the UK.
By using the operator “is not” you can easily list all the members that are not from a specific country. Since the Users Insights filters are stackable, you can use multiple filters at once. For example, filters that show a list of all the members that are not from UK and Australia.
Using BuddyPress custom fields location data
If you have a BuddyPress custom profile field where your members can set their location, thanks to the BuddyPress module of Users Insights, you can use this information to filter your members. When you activate the BuddyPress module of Users Insights you automatically get all the custom fields created with the xProfile fields feature of BuddyPress, available in the user table and the smart filters. So if, for example, you already have a custom field for “Country” that your members complete, you will be able to filter your members by the data that they have set into this custom field.
Using multiple filters
As we have already mentioned, Users Insights allows you to use multiple filters at once. This gives you the ability to segment your BuddyPress members by using multiple properties. The possibilities are endless, but let’s see some interesting examples. Let’s say that you want to find all the members that are from France and are active members of your community. You can do this by adding one filter “Country is France” and a second one “Last Seen is less than 60 days ago”.
But what if we have additional requirements, like the member being male and under a certain age? We can easily do this by adding a third filter for “Gender is Male” and then another filter that only shows members born after January 1, 1984.
See your BuddyPress member locations on the map
Besides the Users Insights user table, the member locations can be also displayed on an interactive map. You can access the map view by clicking on the globe icon above the user table. This map shows all of the detected by Users Insights member locations. Moreover, all of the Users Insights filters are available in the map view, so you can easily filter the members by different criteria and yet preview the segmented list of member locations on the map.
Member Profile Locations
Additionally, the location of each member is displayed on a smaller map in the User Profile section – you can access this page just by clicking on any user from the Users Insights list. This section also lists the country, region and city, as well as the rest of the member related data that Users Insights detects, such as BuddyPress custom fields data, activity, groups info, etc.
This is different from the member address field, a place where members can enter their location data and register it for display and search purposes. This is usually done in order to allow other members to find and contact them easily.
Going deeper with geolocation filtering for BuddyPress
Further to the basic location searches, you can find out your entire BuddyPress member map, by combining the filtering and map functions. Let’s see some examples of how you can do that.
We also mentioned that you have not just the country, but also city and region filters when using the GeoLocation API. Therefore, you can create a BuddyPress map by filtering and platting users from specific locations.
The first BuddyPress map we’re going to create is showing all users from a specific country. First, you can just filter users from that country:
Then, you can use the map feature to see these users on your map.
As you can see, in the map view users who are close to each other are going to be grouped. But it’s very easy to zoom in and out and figure out which users are from which location.
You can also create different maps for each information you need from your users. For instance, you may want to find all Italian-speaking users in New York City using this filter. Then you just switch to the map view:
The BuddyPress member map is going to give you a new look at your customer base. For example, you may find certain neighbourhoods where you have the most active users. This can give you invaluable information about these users, and how to find more users similar to them.
Check out the difference between the table and the map view of this same search:
The map view shows you trends regarding user location, how they are spread, and how appealing your site is for different audiences.
Here is a short video showing you how to use the geolocation feature to search and filter your BuddyPress members:
In the video you can see how easy it is to add and remove filters, and how they can be used in combination with other data.
That’s it! Now you know how to search your BuddyPress members by their location. We hope you found this article helpful and that it will assist you in managing and organizing your BuddyPress community more effectively.