Support » Plugin: Simple User Listing » Show only users with at least 1 post

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author helgatheviking


    This isn’t a parameter that is supported by WP_User_Query, hence it isn’t supported by SUL.

    These posts might be helpful:

    But you’ll probably need to filter pre_user_query. That’s the best I can do as this is too custom an implementation for me to support.

    Useful links indeed 🙂

    My problem is, just as in other posts, to join these mysql queries with the plugin’s script and using WP’s coding.

    Will be searching arround, if I succeed, I will let you know.

    If someone has new ideas, they are welcome here 😉

    Well, I could make it but my solution is useless for you because I have my database modified with a couple of custom columns.

    What I did was basically modify the plugin’s code.

    Search for line 120:

    global $post, $sul_users, $user;

    after this line I have this:

    global $wpdb;
    $superarray = array();
    $exclude_users = $wpdb->get_results("SELECT ID FROM lw_users WHERE last_post_date = '0000-00-00 00:00:00'");
    foreach ($exclude_users as $us)
    { $superarray[] = $us->ID; }

    I changed line 126:

    'exclude' => '',

    and put my array in it, to exclude users I need:

    'exclude' => $superarray,

    so what you need to do is a query to retrieve the IDs of the users you want to exclude.

    It won’t work just like this. It gave me an error, expecting array. So then I changed line 181 and just removed the whole line. Remove this

    $exclude = array_map( 'trim', explode( ',', $exclude ) );


    Plugin Author helgatheviking


    Maybe it would make more sense to select the IDs that you want to include? Instead of altering the plugin’s code (you’ll never never be able to update), I would advise that you filter the user query via pre_user_query. You can even pass a specific query_id in the shortcode parameters, or use the default id of simple_user_listing to specifically target my plugin’s user query.


    I use exclude because it is supposed to have less users with 0 posts than users with 1 or more posts.

    On the other hand, I don’t really worry about the updates for now. I can always modify the code again.

    I don’t know what is the pre_user_query and don’t know how to pass a specific query_id in the shortcode. That would be uselful though…

    Plugin Author helgatheviking


    You pass a query id as a parameter the same way you pass any other parameter. [userlist query_id="users_with_post"]

    pre_user_query is like pre_get_posts for user queries. It lets you change the query arguments before the query is run.

    Maybe I found a far more simple solution, as we already defined $num_posts in content-author.php

    Just change the Template like this:

    $user_info = get_userdata($user->ID);
    $num_posts = count_user_posts ( $user->ID );
    <?php if ($num_posts != 0) echo '
    <div class="author-info author-block">
    <div class="author-avatar">'.get_avatar( $user->ID, 68 ).'</div>
    <div class="author-description"><h2><a href="'.get_author_posts_url($user->ID).'">'.$user_info->display_name.'</a></h2>
    <p class="author-beitraege"><a href="'.get_author_posts_url($user->ID).'">Lese'.$user_info->display_name.'s Beiträge</a></p>
    Plugin Author helgatheviking


    Won’t that make the pagination a little hinky?

    you’re right, but if you don’t need pagination, for the dumber ones like me, it’s ok.

    Sorry I got confused, what was the definitive answer here?

    Plugin Author helgatheviking


    The definitive answer is that posts_per_author (or equivalent) is not a parameter that is supported by WP_User_Query and thus is not supported by SUL. There are potentially some workarounds out there, but they are presumably complex, and not supported by me.

    Sorry, I am still none the wiser. Do you have an example of how to use that posts_per_author (or equivalent)?

    This thread as marked as [resolved] which bit is resolved? I tried the solution by fsx, but that produced a blank page.

    Plugin Author helgatheviking


    The thread is marked as resolved as the question cannot be solved using normal means. posts_per_author does not exist as a parameter. Please see the codex article on WP_User_Query for a list of valid parameters. Since SUL relies on WP_User_Query any parameters not supported or part of WP_User_Query are not supported or available in SUL.

    Fsx’s solution is a partial workaround (ie: it is probably ok if you don’t need pagination, but otherwise may be problematic). I haven’t tested it, but if you are seeing a white screen I presume it may include a typographical error.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Show only users with at least 1 post’ is closed to new replies.