BP_Document::total_document_count( int $user_id )

Count total document for the given user.

Description

Parameters

$user_id

(Required)

Return

(array|bool|int)

Source

File: bp-document/classes/class-bp-document.php

	public static function total_document_count( $user_id = 0 ) {
		global $bp, $wpdb;

		$privacy = array( 'public' );
		if ( is_user_logged_in() ) {
			$privacy[] = 'loggedin';
			if ( bp_is_active( 'friends' ) ) {
				$is_friend = friends_check_friendship( get_current_user_id(), $user_id );
				if ( $is_friend ) {
					$privacy[] = 'friends';
				}
			}
		}
		$privacy = "'" . implode( "', '", $privacy ) . "'";

		$total_count_document = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$bp->document->table_name} WHERE user_id = {$user_id} AND privacy IN ({$privacy}) AND folder_id = 0" );       // db call ok; no-cache ok;
		$total_count_folder   = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$bp->document->table_name_folder} WHERE user_id = {$user_id} AND privacy IN ({$privacy}) AND parent = 0" ); // db call ok; no-cache ok;
		$total_count          = $total_count_folder + $total_count_document;

		return $total_count;
	}

Changelog

Changelog
Version Description
BuddyBoss 1.4.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.