#17123 closed defect (bug) (fixed)
WP_User_Query ordered by post_count doesn't work if prefix is not wp_
Reported by: | ziofix | Owned by: | |
---|---|---|---|
Milestone: | 3.1.2 | Priority: | normal |
Severity: | major | Version: | 3.1 |
Component: | Users | Keywords: | has-patch |
Focuses: | Cc: |
Description
If you try this:
$q = WP_User_Query( array( 'orderby' => 'post_count' ) );
it won't work if your table prefix is different than 'wp_', because it's hard coded in wp-includes/user.php line 441 :
$this->query_from .= " LEFT OUTER JOIN (
SELECT post_author, COUNT(*) as post_count
FROM wp_posts
$where
GROUP BY post_author
) p ON ({$wpdb->users}.ID = p.post_author)
";
it should be replaced by:
$this->query_from .= " LEFT OUTER JOIN (
SELECT post_author, COUNT(*) as post_count
FROM $wpdb->posts
$where
GROUP BY post_author
) p ON ({$wpdb->users}.ID = p.post_author)
";
Attachments (1)
Change History (6)
Note: See
TracTickets for help on using
tickets.
introduced in [15491]