Skip to:
Content

BuddyPress.org

Changeset 9845


Ignore:
Timestamp:
05/06/2015 11:06:09 PM (4 years ago)
Author:
r-a-y
Message:

Messages: Introduce messages_get_message_thread_id() function.

Allows developers to get the thread ID from a single message ID.

See #6331.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-functions.php

    r9819 r9845  
    367367}
    368368
     369/**
     370 * Get the thread ID from a message ID.
     371 *
     372 * @since BuddyPress (2.3.0)
     373 *
     374 * @param  int $message_id ID of the message.
     375 * @return int The ID of the thread if found, otherwise 0.
     376 */
     377function messages_get_message_thread_id( $message_id = 0 ) {
     378    global $wpdb;
     379
     380    $bp = buddypress();
     381
     382    return (int) $wpdb->get_var( $wpdb->prepare( "SELECT thread_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) );
     383}
     384
    369385/** Messages Meta *******************************************************/
    370386
Note: See TracChangeset for help on using the changeset viewer.