Tip: [bps_directory] may not work well with persistent cache plugins. If so, try setting the BuddyPress ‘bp_pages’ cache group to non-persistent.
With BP Profile Search you can create additional member directories using [bps_directory].
[bps_directory]
is not a standard shortcode. It replaces the whole page content area, and can also be used in the BuddyPress Members page to customize the BuddyPress Members directory.
The following sections detail how to use this shortcode.
Click on the section title to show the section content.
A) Create a new member directory
2. Enter the page title;
3. Enter
[bps_directory]
in the page content area;4. Publish your page;
5. Visit your new page, it should display a perfectly good member directory.
B) Use a member directory as the target directory of a search form
2. Locate the Target Directory drop-down in the Form Settings box, and select your target directory;
3. If you wish to display the form in your target directory, select Add Form to Directory: Yes;
4. Update your form;
5. In your front-end, use your search form. The search results should appear in your target directory.
C) Add hidden filters to a member directory
— a field Gender with ID 35 and values Male and Female
— a field Status with ID 56 and values Married and Unmarried
you can build a directory of the married men using the shortcode:
[bps_directory field_35="Male" field_56="Married"]
The available filter types (or search modes) depend on the field content, see below. For a detailed explanation of all the search modes, see the Search Modes page.
Filter types for fields containing text:
contains: [bps_directory field_xy_contains="text to find"]
is: [bps_directory field_xy="text to find"]
is like: [bps_directory field_xy_like="text with wildcards"]
Filter types for fields containing a number:
is: [bps_directory field_xy="number to find"]
range: [bps_directory field_xy_range="from number, to number"]
Filter types for fields containing a date:
is: [bps_directory field_xy="date to find"]
range: [bps_directory field_xy_range="from date, to date"]
age range: [bps_directory field_xy_age_range="from years, to years"]
Filter types for fields containing a single value chosen from a given set (e.g. Drop Down Select Box and Radio Buttons types):
is: [bps_directory field_xy="value to find"]
is one of: [bps_directory field_xy_one_of="value1,value2,..,valueN"]
Filter types for fields containing a set of values chosen from a given set (e.g. Checkboxes and Multi Select Box types):
match any: [bps_directory field_xy_match_any="value1,value2,..,valueN"]
match all: [bps_directory field_xy_match_all="value1,value2,..,valueN"]
match single: [bps_directory field_xy_match_single="value"]
D) Add more sort options to a member directory
To add the option to sort by a profile field, use the shortcode:
[bps_directory order_by="field_xy"]
where xy is the ID of the profile field you wish to use.
For instance, if you have two profile fields, City with ID 2, and Graduation Date with ID 3, the shortcode:
[bps_directory order_by="field_2"]
adds the option City to the Order By drop-down.
When a visitor selects City from the Order By drop-down, the directory (or the search results if a search is active) will be sorted by city, ascending. At the same time, the value of the City field will be displayed in each member’s entry.
The sort direction is asc (ascending) by default, but you can specify desc (descending) or both (both directions), and you can add more than one sort option.
For instance the shortcode:
[bps_directory order_by="field_2 both, field_3 desc"]
adds the options City ⇡, City ⇣ and Graduation Date to the Order By drop-down.
When a visitor selects Graduation Date from the Order By drop-down, the directory (or the search results if a search is active) will be sorted by graduation date, descending. If they select City ⇡ or City ⇣, the directory will be ordered by city, respectively ascending or descending.
E) Modify the standard Members directory template
A few steps are specific to the BuddyPress template pack you are using (legacy or nouveau).
1. Create a directory buddypress inside your active child theme directory
2. Create a directory members inside the new buddypress directory
3. (legacy) Copy the files index.php and members-loop.php from
wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members to the new buddypress/members directory
3. (nouveau) Copy the files index.php and members-loop.php from
wp-content/plugins/buddypress/bp-templates/bp-nouveau/buddypress/members to the new buddypress/members directory
4. Modify the new files index.php and/or members-loop.php to suit your needs
5. Visit your directories, they should reflect your template changes.
F) Create and use a new Members directory template
A few steps are specific to the BuddyPress template pack you are using (legacy or nouveau).
1. Go to the buddypress/members directory you created in procedure E)
2. Copy index.php to index-2.php and members-loop.php to members-loop-2.php
3. (legacy) Edit index-2.php, locate the string ‘members/members-loop’ and replace it with ‘members/members-loop-2’
3. (nouveau) — no action needed —
4. Modify the new files index-2.php and/or members-loop-2.php to suit your needs
5. Edit your directory page, and replace [bps_directory]
with:
[bps_directory template="members/index-2, members/members-loop-2"]
6. Visit your directory, it should reflect your template changes.
You can create as many new templates as you like, and of course you can replace the names index-2.php and members-loop-2.php with names of your choice, as long as you use them consistently as shown in the above steps.