bp_total_follow_counts( array $args = '' )
Get the total followers and total following counts for a user.
Description
Parameters
- $args
-
(Optional) Array of arguments.
- 'user_id'
(int) The user ID to grab follow counts for.
Default value: ''
- 'user_id'
Return
(array) [ followers => int, following => int ]
Source
File: bp-activity/bp-activity-functions.php
4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 | function bp_total_follow_counts( $args = '' ) { $r = wp_parse_args( $args , array ( 'user_id' => bp_loggedin_user_id() ) ); $count = false; /* try to get locally-cached values first */ // logged-in user if ( $r [ 'user_id' ] == bp_loggedin_user_id() && is_user_logged_in() ) { global $bp ; if ( ! empty ( $bp ->loggedin_user->total_follow_counts ) ) { $count = $bp ->loggedin_user->total_follow_counts; } // displayed user } elseif ( $r [ 'user_id' ] == bp_displayed_user_id() && bp_is_user() ) { global $bp ; if ( ! empty ( $bp ->displayed_user->total_follow_counts ) ) { $count = $bp ->displayed_user->total_follow_counts; } } // no cached value, so query for it if ( $count === false ) { $count = BP_Activity_Follow::get_counts( $r [ 'user_id' ] ); } return apply_filters( 'bp_total_follow_counts' , $count , $r [ 'user_id' ] ); } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.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.