Template Overrides
The plugin loads all of its display templates through bp_suggestions_load_template(), which checks your theme directory first. This means you can customize the output without editing plugin files.
How template loading works
Section titled “How template loading works”When the plugin needs to render a layout, it resolves the template file in this order:
- Child theme —
{child-theme}/buddypress-friend-follow-suggestions/{filename} - Parent theme —
{parent-theme}/buddypress-friend-follow-suggestions/{filename} - Plugin fallback —
{plugin}/templates/{filename}
If neither theme directory contains the file, the plugin uses its own template.
Overridable templates
Section titled “Overridable templates”| Template file | Purpose | Used by |
|---|---|---|
list-layout.php |
Vertical list of suggestion cards | List widget, [bp_friend_suggestions layout="list"] |
horizontal-layout.php |
Horizontal Swiper slider | Horizontal slider widget |
horizontal-slider-layout.php |
Full-featured Swiper with nav/pagination | Swiper widget variant |
Creating a theme override
Section titled “Creating a theme override”Copy the template you want to modify from the plugin into your theme:
# Example: override the list layoutmkdir -p your-theme/buddypress-friend-follow-suggestions/cp wp-content/plugins/buddypress-friend-follow-suggestion/templates/list-layout.php \ wp-content/themes/your-theme/buddypress-friend-follow-suggestions/list-layout.phpEdit the copy in your theme. The plugin will automatically pick it up — no configuration required.
Variables available in templates
Section titled “Variables available in templates”Every template receives a $settings array. The keys present depend on whether the template is loaded by a widget or shortcode:
| Key | Type | Source | Description |
|---|---|---|---|
suggest |
string |
All | 'friends' or 'follow' |
limit |
int |
All | Maximum members to display |
show_reset_button |
bool |
Widget | Whether to show the “Show New People” button |
swiper_autoplay |
bool |
Swiper widget | Enable autoplay |
swiper_autoplay_delay |
int |
Swiper widget | Delay in milliseconds |
swiper_loop |
bool |
Swiper widget | Enable continuous loop |
swiper_slides_per_view |
int |
Swiper widget | Visible slides at once |
swiper_space_between |
int |
Swiper widget | Gap between slides (px) |
swiper_show_navigation |
bool |
Swiper widget | Show prev/next arrows |
swiper_show_pagination |
bool |
Swiper widget | Show dot pagination |
swiper_centered_slides |
bool |
Swiper widget | Center-align slides |
UX settings (dismiss button, match details) are read directly from BFFS_UX inside the template — they are not passed through $settings.
Gutenberg block template override
Section titled “Gutenberg block template override”The bffs/suggestions block uses a separate render file that also supports theme overrides:
{theme}/buddypress-friend-follow-suggestion/blocks/suggestions/render.phpNote the singular form (buddypress-friend-follow-suggestion) rather than the plural form used by widget/shortcode templates. The block’s render file is a thin loader — copy the plugin’s blocks/suggestions/render.php and place it at the path above.
Using template actions in overrides
Section titled “Using template actions in overrides”Rather than copying full templates, consider hooking into the template actions to inject content at specific points. This approach survives plugin updates without requiring you to re-merge template changes:
// Add a "New Member" badge after every avatar, without overriding the templateadd_action( 'bffs_after_member_avatar', function( $member_id, $settings ) { $registered = get_userdata( $member_id )->user_registered; if ( strtotime( $registered ) > strtotime( '-7 days' ) ) { echo '<span class="bffs-new-member-badge">' . esc_html__( 'New', 'your-text-domain' ) . '</span>'; }}, 10, 2 );CSS classes to target
Section titled “CSS classes to target”All layouts output consistent class names. Use these in your theme stylesheet to adjust appearance:
| Class | Element |
|---|---|
.bffs_swiper_layout_wrapper |
Swiper container |
.bffs_horizontal_layout |
Horizontal layout container |
#members-list |
List/horizontal layout <ul> or <div> |
.bffs-slide.swiper-slide |
Individual slide in Swiper layout |
.item-entry |
Individual member card (bp_member_class() target) |
.item-avatar |
Avatar wrapper |
.item-title.fn |
Member name |
.bffs-dismiss-suggestion |
“Not Interested” button |
.bffs-show-match-details |
“Show Match Details” button |
.bffs-match-details-container |
Expandable match details panel |
.bffs-reset-container |
“Show New People” button wrapper |
.bffs-reset-suggestions |
“Show New People” button |
.member-status.online |
Online indicator dot |
RTL support
Section titled “RTL support”All built-in templates use is_rtl() to load RTL-specific stylesheets. If you replace a template, keep the RTL stylesheet loading in place:
if ( is_rtl() ) { wp_enqueue_style( 'your-bffs-rtl', get_stylesheet_directory_uri() . '/css/bffs-rtl.css' );}
