Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/12/2021 02:09:02 PM (3 years ago)
Author:
imath
Message:

Support date queries for Members, Groups and Sites

According to components, date queries can be restricted to a limited list of loop types:

  • For Members, the $type parameter in bp_has_members() needs to be either active, newest, random or online.
  • For Groups, the $type parameter in bp_has_groups() needs to be either active or newest.
  • For sites, the $type parameter in bp_has_blogs() needs to be either active or newest.

Props r-a-y

Fixes #8488

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-user-query.php

    r13108 r13184  
    1818 *
    1919 * @since 1.7.0
     20 * @since 10.0.0 Added $date_query parameter.
    2021 *
    2122 * @param array $query {
     
    5051 *     @type array             $xprofile_query      Filter results by xprofile data. Requires the xprofile component.
    5152 *                                                  See {@see BP_XProfile_Query} for details.
     53 *     @type array             $date_query          Filter results by member last activity date. See first parameter of
     54 *                                                  {@link WP_Date_Query::__construct()} for syntax. Only applicable if
     55 *                                                  $type is either 'active', 'random', 'newest', or 'online'.
    5256 *     @type bool              $populate_extras     True if you want to fetch extra metadata
    5357 *                                                  about returned users, such as total group and friend counts.
     
    173177                    'meta_value'          => false,
    174178                    'xprofile_query'      => false,
     179                    'date_query'          => false,
    175180                    'populate_extras'     => true,
    176181                    'count_total'         => 'count_query',
     
    283288                $sql['order']   = "DESC";
    284289
     290                // Date query.
     291                $date_query = BP_Date_Query::get_where_sql( $date_query, 'u.date_recorded' );
     292                if ( ! empty( $date_query ) ) {
     293                    $sql['where']['date_query'] = $date_query;
     294                }
     295
    285296                break;
    286297
     
    303314                    $sql['orderby'] = "ORDER BY u.date_recorded";
    304315                    $sql['order'] = "DESC";
     316                }
     317
     318                // Date query.
     319                $date_query = BP_Date_Query::get_where_sql( $date_query, 'u.date_recorded' );
     320                if ( ! empty( $date_query ) ) {
     321                    $sql['where']['date_query'] = $date_query;
    305322                }
    306323
Note: See TracChangeset for help on using the changeset viewer.