BP_Activity_Follow::get_counts( int $user_id )

Get the follower / following counts for a given user.

Description

Parameters

$user_id

(int) (Required) The user ID to fetch counts for.

Return

(array)

Source

File: bp-activity/classes/class-bp-activity-follow.php

	public static function get_counts( $user_id ) {
		global $bp, $wpdb;

		$followers = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->activity->table_name_follow} WHERE leader_id = %d", $user_id ) );
		$following = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->activity->table_name_follow} WHERE follower_id = %d", $user_id ) );

		return array( 'followers' => $followers, 'following' => $following );
	}

Changelog

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.