You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Expose basic details for users with published posts #839
GET /wp/users currently requires a user to have list_users cap. We should expose all users who have any published content for public post types.
Core doesn't have a sane way to query this, me thinks :( #838 implements this for GET /wp/users/<id> for published posts, but we should support all post types.
Currently we allow /users/<id> for any author that has a published post of post_type = post. I'd recommend we use get_posts_by_author_sql to get those users and roll with that.
Our issue is that we don't really want to do SQL queries in the API, since it doesn't belong there. What we need is a way for WP_User_Query to use get_posts_by_author_sql for the query rather than just allowing sorting by it. This also means that it works nicely with wp_is_large_network, any caching layers that may be in place with user query filters, etc.
Activity
TimothyBJacobs commentedon Feb 5, 2015
I think something like this could work, basic and untested.
and the sql.
danielbachhuber commentedon Feb 5, 2015
Another consideration: performance. Our queries should be behind some basic object cache so we don't make the same query over and over
rmccue commentedon Feb 11, 2015
Can we use
get_users( [ 'who' => 'authors' ] )? Not sure if that's robust enough.rmccue commentedon Feb 11, 2015
Ah, checking the source reveals that it's any user with a user level > 0, so could be too much.
However you can order by
post_count, which should also give back thepost_countcolumn, so that might work.rachelbaker commentedon Apr 15, 2015
Punting to Beta 2.
joehoyle commentedon Apr 30, 2015
Currently we allow
/users/<id>for any author that has a published post of post_type = post. I'd recommend we useget_posts_by_author_sqlto get those users and roll with that.rmccue commentedon May 3, 2015
Our issue is that we don't really want to do SQL queries in the API, since it doesn't belong there. What we need is a way for
WP_User_Queryto useget_posts_by_author_sqlfor the query rather than just allowing sorting by it. This also means that it works nicely withwp_is_large_network, any caching layers that may be in place with user query filters, etc.joehoyle commentedon May 16, 2015
Trac ticket: https://core.trac.wordpress.org/ticket/32250#comment:8 looks to be making some progress.
rachelbaker commentedon May 25, 2015
Trac Ticket is making progress, but punting to Beta 3 to see how this pans out.
johnbillion commentedon Jun 2, 2015
https://core.trac.wordpress.org/ticket/32250 is in.
joehoyle commentedon Jun 15, 2015
Will handle a PR for this by tomorrow, so leaving in b3 for now.