Skip to:
Content

Changeset 11867


Ignore:
Timestamp:
02/28/2018 02:48:30 PM (5 months ago)
Author:
djpaul
Message:

Activity: support searching by author slug.

Non-user facing change. Requires a filter to be applied.

Fixes #3889

Props tw2113

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-activity.php

    r11692 r11867  
    457457            $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
    458458            $where_conditions['search_sql'] = $wpdb->prepare( 'a.content LIKE %s', $search_terms_like );
     459
     460            /**
     461             * Filters whether or not to include users for search parameters.
     462             *
     463             * @since 3.0.0
     464             *
     465             * @param bool $value Whether or not to include user search. Default false.
     466             */
     467            if ( apply_filters( 'bp_activity_get_include_user_search', false ) ) {
     468                $user_search = get_user_by( 'slug', $r['search_terms'] );
     469                if ( false !== $user_search ) {
     470                    $user_id                         = $user_search->ID;
     471                    $where_conditions['search_sql'] .= $wpdb->prepare( ' OR a.user_id = %d', $user_id );
     472                }
     473            }
    459474        }
    460475
Note: See TracChangeset for help on using the changeset viewer.