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
1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 | 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
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.