Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    This is not possible with the current plugin. I realized that the loop itself is hard-coded in place. I have dabbled with changing that here in a developmental version: https://github.com/helgatheviking/Simple-User-Listing/tree/feature/loop

    If you will test out that version, and assuming your shortcode is [userlist query_id="search_only"] you could then use the following code:

    
    function kia_customize_user_listing( $query_id ) {
        if( 'search_only' == $query_id && ! isset( $_GET['as' ] ) ) {
            remove_action( 'simple_user_listing_before_loop', array( Simple_User_Listing::get_instance(), 'open_wrapper' ), 20 );
    		remove_action( 'simple_user_listing_loop', array( Simple_User_Listing::get_instance(), 'user_loop' ) );
    		remove_action( 'simple_user_listing_after_loop', array( Simple_User_Listing::get_instance(), 'close_wrapper' ), 5 );
    		remove_action( 'simple_user_listing_after_loop', array( Simple_User_Listing::get_instance(), 'add_nav' ) );
        }
    }
    add_action( 'simple_user_listing_before_loop', 'kia_customize_user_listing', 1 );
    

    to remove the loop. Now, I think this means the query still ran, so it may not be the most performant thing depending on how complex the query is.

    I don’t have time to do full testing, but additionally, you could do this:

    
    function kia_nullify_query( $args, $query_id, $atts ) {
        if( 'search_only' == $query_id && ! isset( $_GET['as' ] ) ) {
            $args = array( 'include' => array( 0 ) );
        }
        return $args;
    }
    add_filter( 'sul_user_query_args', 'kia_nullify_query', 10, 3 );
    

    which may sort of “short-circuit” the query (a query will still run though, so I am not sure you can fully avoid that) and then you can remove the loop the same as above.

    Let me know what you think. And remember this is still quite developmental so don’t use it on a production site until you have tested it thoroughly.

    And if this has been helpful to you, please consider sending a donation to my sports team: https://www.paypal.me/usathwnt

    Thread Starter domino4evers

    (@domino4evers)

    Hi Helga

    Thanks for the code.

    1. I am using the shortcode [userlist meta_key="first_name" orderby="meta_value" order="ASC" number="2000" userlist role="dc_vendor"]

    I’m not all sure I understand where to put all the codes you are referring to? And should I download the new version you are linking to?

    UPDATE:
    I have added the shortcode: [userlist query_id="search_only" meta_key="first_name" orderby="meta_value" order="ASC" number="2000" userlist role="dc_vendor"] to the page.

    And the code you wrote to my functions.php. Well i do not search at start, but comes with a “No user found” error.

    • This reply was modified 5 years, 9 months ago by domino4evers.
    Plugin Author HelgaTheViking

    (@helgatheviking)

    The code snippet that I wrote goes in your theme’s functions.php. While it’s still pretty experimental, it won’t do anything (like remove the No users found text) unless you update the Simple User Listing plugin to the developmental version found here: https://github.com/helgatheviking/Simple-User-Listing/archive/feature/loop.zip

    Do you have any users with the dc_vendor role configured?

    Thread Starter domino4evers

    (@domino4evers)

    Wow! It works like a charm!

    Thanks!

    One small question, how do I implement a call for a Anchor in the search query? Like #results

    Plugin Author HelgaTheViking

    (@helgatheviking)

    Glad to hear it! One of these days I will package it up and make it the official release.

    If you want to skip right to the #results you could maybe add #results in the form action. You would need to copy the plugin’s search-author.php template to your theme and then modify

    
    <form method="get" id="sul-searchform" action="">
    

    to

    
    <form method="get" id="sul-searchform" action="#results">
    

    That’s just a guess, I don’t know if it will work. Good luck.

    Thread Starter domino4evers

    (@domino4evers)

    Yeah! It works! Thanks ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Blank page for startup?’ is closed to new replies.