WordPress.org

Ready to get started?Download WordPress

Forums

Simple User Listing
[resolved] Results are listed before post content (8 posts)

  1. benutzerfreund
    Member
    Posted 1 year ago #

    Great PlugIn, thanks a lot.

    I got everything working, except one thing: The author list is listed before the other text on my page.

    I used:

    <h2>Die Autoren unseres Blogs</h2>
    <p>sekjhfkjhsrf</p>
    <p>[userlist role="" number="5" orderby="post_count" order="DESC"]</p>

    What I get is this HTML:

    <div class="entry-content">
    					<!-- FIX-jj no search --><div id="user-13" class="author-block">
    	<p>Peter Pan</p>
    </div>
    <div id="user-3" class="author-block">
    	<p>Hans Hammer</p>
    </div>
    <div id="user-12" class="author-block">
    	<p>Anja All</p>
    </div>
    <!-- FIX-jj no pagination --><h2>Die Autoren unseres Blogs</h2>
    <p>sekjhfkjhsrf</p>
    
    									</div>

    What did I get wrong?

    Thanks for your help in advance,
    Jens

    http://wordpress.org/plugins/simple-user-listing/

  2. helgatheviking
    Member
    Plugin Author

    Posted 1 year ago #

    You didn't get anything wrong. Apparently I've been echoing the shortcode this entire time! #facepalm. Please update, and it will return like a proper shortcode now.

    Thanks for the heads up. I can't believe no one noticed this sooner.

  3. benutzerfreund
    Member
    Posted 1 year ago #

    Wow, thank you for the super fast answer!

    And now it works like a charm.

    Unfortunately, I ran into some limitations. Maybe you could help me with this... I need a list of all "admin" AND "editor" users, sorted by their last name. Since WP_User_Query doesn't support returning several roles and doesn't support sorting by user_lastname, I can't use your PlugIn for this, right?

    Any other ideas?

    Thanks again,
    Jens

  4. helgatheviking
    Member
    Plugin Author

    Posted 1 year ago #

    You're welcome. WP_User_Query does not support querying for multiple roles, which is a shame. It is something I would consider for a premium version (because there must be a workaround), but I have no immediate plans for that.

    You can probably sort by last name however. I just helped someone in another thread search by display name, so I would guess it is possible if you get the query_where (and maybe sort_by) code right when filtering pre_user_query

    See my code in the other thread:
    http://wordpress.org/support/topic/new-filter?replies=24

  5. benutzerfreund
    Member
    Posted 1 year ago #

    It is really a shame. I did a workaround now with a dumb if-clause to exclude some roles now. Not elegant nor fast, but it works for me.

    Thanks again!

  6. helgatheviking
    Member
    Plugin Author

    Posted 1 year ago #

    I thought I had found the solution here:
    http://wordpress.stackexchange.com/questions/39315/get-multiple-roles-with-get-users/88158#answer-88158

    But I haven't been able to get it to work yet.

  7. benutzerfreund
    Member
    Posted 1 year ago #

    Yes, this works. But it doesn't solve my sorting problem. So the solution I opt for is

    $args  = array(
        'meta_key' => 'last_name',
        'role'     => ''
    );
    
    $wp_user_query = new WP_User_Query($args);
    $wp_user_query->query_orderby = str_replace( 'user_login', 'wp_usermeta.meta_value', $wp_user_query->query_orderby );
    $wp_user_query->query();
    
    $authors = $wp_user_query->get_results();

    Then I go through this list and check if user has the role I just want to show.

    Just in case anyone could use this.

  8. helgatheviking
    Member
    Plugin Author

    Posted 1 year ago #

    Cool. Thanks for sharing, though I think you can do query_orderby using pre_user_query as currently I think you are querying twice, and it is already a slow query.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.