Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
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

Closed

Description

@danielbachhuber

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.

Activity

  1. added this to the 2.0 milestone on Feb 5, 2015
  2. TimothyBJacobs commented on Feb 5, 2015

    @TimothyBJacobs
    Member

    I think something like this could work, basic and untested.

    $types = get_post_types( array( 'public' => true ) );
    $types = implode( $types, ', ' );

    and the sql.

    SELECT `post_author` FROM `wp_posts` WHERE `post_type` IN ( $types );
  3. danielbachhuber commented on Feb 5, 2015

    @danielbachhuber
    MemberAuthor

    Another consideration: performance. Our queries should be behind some basic object cache so we don't make the same query over and over

  4. rmccue commented on Feb 11, 2015

    @rmccue
    Member

    Core doesn't have a sane way to query this, me thinks :(

    Can we use get_users( [ 'who' => 'authors' ] ) ? Not sure if that's robust enough.

  5. rmccue commented on Feb 11, 2015

    @rmccue
    Member

    Not sure if that's robust enough.

    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 the post_count column, so that might work.

  6. rachelbaker commented on Apr 15, 2015

    @rachelbaker
    Member

    Punting to Beta 2.

  7. joehoyle commented on Apr 30, 2015

    @joehoyle
    Member

    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.

  8. rmccue commented on May 3, 2015

    @rmccue
    Member

    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.

  9. self-assigned this
    on May 13, 2015
  10. joehoyle commented on May 16, 2015

    @joehoyle
    Member

    Trac ticket: https://core.trac.wordpress.org/ticket/32250#comment:8 looks to be making some progress.

  11. rachelbaker commented on May 25, 2015

    @rachelbaker
    Member

    Trac Ticket is making progress, but punting to Beta 3 to see how this pans out.

  12. johnbillion commented on Jun 2, 2015

    @johnbillion
    Contributor
  13. joehoyle commented on Jun 15, 2015

    @joehoyle
    Member

    Will handle a PR for this by tomorrow, so leaving in b3 for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions