Skip to:
Content

BuddyPress.org

Ticket #7864: 7864.patch

File 7864.patch, 1.4 KB (added by dipesh.kakadiya, 2 years ago)

Added patch file to search message by user ( sender and receiver )

  • src/bp-messages/classes/class-bp-messages-thread.php

    diff --git a/src/bp-messages/classes/class-bp-messages-thread.php b/src/bp-messages/classes/class-bp-messages-thread.php
    index c868d554f..ccb8a8ffa 100644
    a b class BP_Messages_Thread { 
    487487                        $type_sql = " AND r.unread_count = 0 ";
    488488                }
    489489
     490                $bp = buddypress();
    490491                if ( ! empty( $r['search_terms'] ) ) {
    491492                        $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
    492                         $search_sql        = $wpdb->prepare( "AND ( subject LIKE %s OR message LIKE %s )", $search_terms_like, $search_terms_like );
     493                        $search_sql        = $wpdb->prepare( "AND ( subject LIKE %s OR message LIKE %s ", $search_terms_like, $search_terms_like );
     494                        $search_sql       .= "OR r.thread_id in( SELECT thread_id from {$bp->messages->table_name_recipients} r1 INNER JOIN {$wpdb->users} user ON user.ID = r1.user_id where ";
     495                        $search_sql       .= $wpdb->prepare( "r1.user_id != %d AND ( user_login like %s or display_name like %s) )", $r['user_id'], $search_terms_like, $search_terms_like );
     496                        $search_sql       .= ' )';
    493497                }
    494498
    495499                $r['user_id'] = (int) $r['user_id'];
    class BP_Messages_Thread { 
    523527                        $meta_query_sql['where'] = $meta_query['where'];
    524528                }
    525529
    526                 $bp = buddypress();
    527 
    528530                // Set up SQL array.
    529531                $sql = array();
    530532                $sql['select'] = 'SELECT m.thread_id, MAX(m.date_sent) AS date_sent';