Quantcast
Channel: Code Recipe Posts for Extending Your Membership Site
Viewing all articles
Browse latest Browse all 326

Allow Users to Filter Results in your Member Directory

$
0
0

This code recipe demonstrates how to allow users to filter results shown by the Member Directory and Profile Pages Add On by adding a widget to the member directory’s sidebar. This feature allows users to search through your member directory more effectively while also improving their experience on your site.

Allow Users to Filter Results in your Member Directory


About the Code Recipe

The Member Directory and Profile Pages Add On provides a shortcode to display your site’s members and information about those members in a variety of different layouts. This functionality is typically used to give users a means of finding members on the site. As your site grows, it becomes increasingly difficult to find the particular member information that your users are searching for.

One way to combat this issue is by providing filterable values that users can select to narrow their search and allowing them to more easily find the member that they are looking for. This code recipe gives you the functionality to do just that.


Full Directory (no filters selected)

Allow Users to Filter Results in your Member Directory


Filtered Directory View

Filtered View of PMPro Member Directory


Setting Up Your Member Directory Filter Widget

  1. 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.
  2. Add your filterable fields to the widget by updating the widget() function (specifically lines 36-90 at the time of writing).
  3. Update the SQL query based on user input into the fields you created in the my_pmpro_directory_widget_filter_sql_parts() function.
  4. Insert the widget into a sidebar shown on your Member Directory page via the WordPress Appearance > Widgets screen. This widget will not show any content on pages without the member directory shortcode.
  5. Test to make sure that your filters are working as expected.

The Code Recipe

This code recipe requires a Plus Account or higher.

View Membership Options


David Parker

This code recipe was written by our very own David Parker.


Viewing all articles
Browse latest Browse all 326

Trending Articles