BP_Messages_Thread::get_messages_count( int $thread_id )
Count the totla message in thread
Description
Parameters
- $thread_id
-
(Required)
Source
File: bp-messages/classes/class-bp-messages-thread.php
public static function get_messages_count( $thread_id ) {
global $wpdb;
$bp = buddypress();
$thread_id = (int) $thread_id;
if ( ! static::is_thread_recipient( $thread_id ) ) {
return 0;
}
$last_deleted_timestamp = static::$last_deleted_message? static::$last_deleted_message->date_sent : '0000-00-00 00:00:00';
$results = $wpdb->get_col( $sql = $wpdb->prepare(
"SELECT COUNT(*) FROM {$bp->messages->table_name_messages}
WHERE thread_id = %d
AND date_sent > %s
", $thread_id, $last_deleted_timestamp ) );
return intval( $results[0] );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 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.