Make WordPress Core

Changeset 29934


Ignore:
Timestamp:
10/17/2014 01:36:36 AM (12 years ago)
Author:
boonebgorges
Message:

Support date_query by user_registered in WP_User_Query.

Props ChriCo, nacin.
Fixes #27283.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/date.php

    r29933 r29934  
    452452                $valid_columns = array(
    453453                        'post_date', 'post_date_gmt', 'post_modified',
    454                         'post_modified_gmt', 'comment_date', 'comment_date_gmt'
     454                        'post_modified_gmt', 'comment_date', 'comment_date_gmt',
     455                        'user_registered',
    455456                );
    456457
     
    464465                         * @param array $valid_columns An array of valid date query columns. Defaults
    465466                         *                             are 'post_date', 'post_date_gmt', 'post_modified',
    466                          *                             'post_modified_gmt', 'comment_date', 'comment_date_gmt'
     467                         *                             'post_modified_gmt', 'comment_date', 'comment_date_gmt',
     468                         *                             'user_registered'
    467469                         */
    468470                        if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) {
     
    481483                                        'comment_date_gmt',
    482484                                ),
     485                                $wpdb->users => array(
     486                                        'user_registered',
     487                                ),
    483488                        );
    484489
  • trunk/src/wp-includes/user.php

    r29843 r29934  
    741741                        $ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
    742742                        $this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
     743                }
     744
     745                // Date queries are allowed for the user_registered field.
     746                if ( ! empty( $qv['date_query'] ) && is_array( $qv['date_query'] ) ) {
     747                        $date_query = new WP_Date_Query( $qv['date_query'], 'user_registered' );
     748                        $this->query_where .= $date_query->get_sql();
    743749                }
    744750
Note: See TracChangeset for help on using the changeset viewer.