bp_blogs_get_profile_stats( array|string $args = '' )

Return the number of blogs in user’s profile.

Description

Parameters

$args

(Optional) Before|after|user_id.

Default value: ''

Return

(string) HTML for stats output.

Source

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

1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
function bp_blogs_get_profile_stats( $args = '' ) {
 
    // Parse the args.
    $r = bp_parse_args( $args, array(
        'before'  => '<li class="bp-blogs-profile-stats">',
        'after'   => '</li>',
        'user_id' => bp_displayed_user_id(),
        'blogs'   => 0,
        'output'  => ''
    ), 'blogs_get_profile_stats' );
 
    // Allow completely overloaded output.
    if ( is_multisite() && empty( $r['output'] ) ) {
 
        // Only proceed if a user ID was passed.
        if ( ! empty( $r['user_id'] ) ) {
 
            // Get the user's blogs.
            if ( empty( $r['blogs'] ) ) {
                $r['blogs'] = absint( bp_blogs_total_blogs_for_user( $r['user_id'] ) );
            }
 
            // If blogs exist, show some formatted output.
            $r['output'] = $r['before'] . sprintf( _n( '%s site', '%s sites', $r['blogs'], 'buddyboss' ), '<strong>' . $r['blogs'] . '</strong>' ) . $r['after'];
        }
    }
 
    /**
     * Filters the number of blogs in user's profile.
     *
     * @since BuddyPress 2.0.0
     *
     * @param string $value Output determined for the profile stats.
     * @param array  $r     Array of arguments used for default output if none provided.
     */
    return apply_filters( 'bp_blogs_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.