[wp-trac] [WordPress Trac] #23228: get_users() cannot include AND exclude
WordPress Trac
noreply at wordpress.org
Thu Jan 17 22:45:52 UTC 2013
#23228: get_users() cannot include AND exclude
-----------------------------+--------------------------
Reporter: dlim_vernier | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: Users
Version: 3.5 | Severity: normal
Keywords: |
-----------------------------+--------------------------
The codex describes the parameters for get_users() as an array of options,
so it seems like you can set an array of includes and an array of
excludes. But the code looks like it can only do one or the other. It
would be a simple fix.
Lines 521-527 in wp-includes/user.php
{{{
if ( !empty( $qv['include'] ) ) {
$ids = implode( ',', wp_parse_id_list( $qv['include'] ) );
$this->query_where .= " AND $wpdb->users.ID IN ($ids)";
} elseif ( !empty($qv['exclude']) ) {
$ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
$this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
}
}}}
To fix, change the elseif to its own if:
{{{
if ( !empty( $qv['include'] ) ) {
$ids = implode( ',', wp_parse_id_list( $qv['include'] ) );
$this->query_where .= " AND $wpdb->users.ID IN ($ids)";
}
if ( !empty($qv['exclude']) ) {
$ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
$this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
}
}}}
Thanks for the consideration.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23228>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list