How to search and filter your members by BuddyPress groups
In this tutorial, I’m going to show you how to improve the management of your BuddyPress community members by using the BuddyPress groups data, with the help of Users Insights.
BuddyPress groups are mainly used to organize members of the community based on their shared interests, role, goals etc. This allows the creation of small mini-communities with their own pages, activity streams and directory. This is all great, but when it comes for the administrators and the community moderators to figure out who is part of which group, who created the groups etc., it can be bit of a challenge. This is where the BuddyPress module for Users Insights comes in handy.
First, let’s see which Users Insights features can help you get more from your BuddyPress groups. Users Insights gives you the ability to filter your BuddyPress members by the groups that they belong/do not belong to, as well as by the number of groups that they belong to and have created. Here are some of the possible options that we can do with the Users Insights group filters:
- Filter the members by the BuddyPress group they belong to
- Filter the BuddyPress members by the number of groups that they belong to
- List the BuddyPress members who have created the most/least number of groups
- List all the members that are members of two or more specific groups
- Filter the members who are a member of group A but are not a member of group B
- List all BuddyPress members that have not created a group yet
First you have to make sure that you have the Users Insights plugin installed on your BuddyPress website and that you have the BuddyPress module activated. You can activate the BuddyPress module from the Module Options page of Users Insights in your WordPress dashboard.
Once the BuddyPress module is activated, you will have all the BuddyPress related fields automatically added to your Users Insights user list. All the additional BuddyPress filters will be also available via the “Add Filter” button.
Finding the members that belong (or not) to a particular group
If you visit a group’s page in your WordPress admin, you can get a full list of all the users that are members of that particular group. The Group filters of Users Insights, however, provide you with a little more functionality so you can create more interesting user group filters right from the Users Insights user list. Let’s see some examples.
To show a list of all the members that belong to a particular BuddyPress group, all we need to do is add a filter “Group is” and select the group name from the list. Here is an example of all the users who belong to the group “Book Lovers”:
If we want to get a list of all the members who belong to a particular group but not to another, we just need to add a second filter with the operator “Group is not”. Here is a list of all the members of our community that belong to the group “Cricket Fans” but are not part of the group “Tennis”:
We can, of course, use the same filter to only show the members who don’t belong to a specific group, like for example, all the members who do not belong to the group “Sport Community”:
Filtering members by the number of BuddyPress groups that they belong to
If you click on the “Add Filter” button, you will notice that there is a filter called “Group Number” in the list of available filters. This is a filter that allows you to filter your users by the number of groups that they belong to. You have the option to select the exact number by selecting the “is” operator from the available options – here is an example where we have listed all the members that do not belong to any group:
You can also select the option “is bigger” or “is smaller” that allows you to set a lower or upper limit of the number of groups that the members belong to.
Since the Users Insights filters are stackable, you can also create user filters with multiple parameters. For example, you can make a filter that shows all the BuddyPress members that are members of more than 8 groups but less than 12 groups:
You can also use the group filter with the combination of any of the other Users Insights smart filters. For example, you can apply a filter that allows you to filter your BuddyPress members by their location. To shows all the BuddyPress members that are members of more than 4 groups and are from France:
Please note that in order for the above filter to be available you will have to make sure that you have the Geolocation Module activated, that comes bundled with Users Insights.
Finding the top groups creators
Another BuddyPress group related filter that is available from the filter list is the “Groups Created” filter. This filter in a similar way allows you to filter your BuddyPress members by the number of BuddyPress groups that they have created.
Similarly, there is an option to use the “Groups created is bigger than X” or “Groups created is smaller than X” filters:
Combining BuddyPress group filters with other filters
As you have probably noticed by now, the Users Insights filters allow you to combine two or more filters to further segment your member list. Let’s see some examples of what is possible. Let’s say that you have applied a filter that shows you all the users who are members of a particular group. Now let’s say that you want to see who are the members of that group that have been active recently. We can do this by using the “Last seen” filter. We can add a filter that will show us only the members of the group that have been online in the last 30 days:
Now we can go even a step further and filter the group by any of the registered BuddyPress xProfile fields. For example, if we have a BuddyPress user field “Age”, we could apply an additional filter to further segment the users by their age:
That is it. Now you know how to use the BuddyPress group filters of Users Insights to create a segmented list of your BuddyPress members with the exact properties that you might need. We hope that this article was useful and that it is going to help you improve your BuddyPress community management and organization.