not_friends are in fact members
. Are you sure you want to built this, as such widget already exist ! Ok, has no Add Friend button…
BuddyPress Widgets
Another solution would be to use a shortcode who will fire a kind of Members widget and the add friend button. Huh ? 🙂
Add this snippet to bp-custom.php
function show_our_members( $atts ) {
$user_id = bp_displayed_user_id();
/**
* Options
* type:active, newest, popular, online, alphabetical, random)
* number:number of items
* size:size of avatar in px
*/
$atts = shortcode_atts( array(
'type' => 'newest',
'number' => '10',
'size' => '30'
), $atts, 'ourmembers' );
if ( bp_has_members( 'type='.$atts['type'].'&max='.$atts['number'] ) ) :
while ( bp_members() ) : bp_the_member(); ?>
<ul><li class="vcard">
<div class="item-avatar">
<a>"><?php bp_member_avatar(); ?></a>
</div>
<div class="item">
<div class="item-title fn"><a>" title="<?php bp_member_name(); ?>"><?php bp_member_name(); ?></a></div>
<div class="item-meta"><?php bp_add_friend_button( $user_id ); ?></div>
</div>
</li></ul>
<?php
endwhile;
endif;
}
add_shortcode( 'ourmembers', 'show_our_members' );
The shortcode to use (in post, pages, widgets…), eg. [ourmembers size=20 type=newest number=8]
The only thing you have to do, is to style it accordingly to your theme layout.
Note that the classes are those used in BP’s Members widget. You can use them or add your own.
@danbp thank you for your reply.
You’re welcome! Is snippet working for you ?