bp_friends_get_profile_stats( array|string $args = '' )

Return the number of friends in user’s profile.

Description

Parameters

$args

(Optional) before|after|user_id.

Default value: ''

Return

(string) HTML for stats output.

Source

File: bp-friends/bp-friends-template.php

793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
function bp_friends_get_profile_stats( $args = '' ) {
 
    // Parse the args.
    $r = bp_parse_args( $args, array(
        'before'  => '<li class="bp-friends-profile-stats">',
        'after'   => '</li>',
        'user_id' => bp_displayed_user_id(),
        'friends' => 0,
        'output'  => ''
    ), 'friends_get_profile_stats' );
 
    // Allow completely overloaded output.
    if ( empty( $r['output'] ) ) {
 
        // Only proceed if a user ID was passed.
        if ( ! empty( $r['user_id'] ) ) {
 
            // Get the user's friends.
            if ( empty( $r['friends'] ) ) {
                $r['friends'] = absint( friends_get_total_friend_count( $r['user_id'] ) );
            }
 
            // If friends exist, show some formatted output.
            $r['output'] = $r['before'] . sprintf( _n( '%s connection', '%s connections', $r['friends'], 'buddyboss' ), '<strong>' . $r['friends'] . '</strong>' ) . $r['after'];
        }
    }
 
    /**
     * Filters the number of friends in user's profile.
     *
     * @since BuddyPress 2.0.0
     *
     * @param string $value Formatted string displaying total friends count.
     * @param array  $r     Array of arguments for string formatting and output.
     */
    return apply_filters( 'bp_friends_get_profile_stats', $r['output'], $r );
}

Changelog

Changelog
Version Description
BuddyPress 2.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.