Support » Plugin: Simple User Listing » Search by dropdown?

  • Hi 🙂

    I love your plugin. It’s great because it’s simple. I just have one problem. I’m trying to change ‘text’ field to drop down with options taken from database. To change meta keys I used function from your FAQ. And in ‘author-search.php’ I put this code:

    global $wpdb;
    			$qry1 = "select * from wp_terms";
    			$reg1 = $wpdb->get_results($qry1);
    			if(!empty($reg1))
    			{
    				echo '<select>';
    				foreach($reg1 as $row1)
    				{
      					echo '<option class="field" name="as" id="sul-s" value='.$search.'>'.$row1 -> name.'</option>';
    				}
    				echo '</select> ';
    			}

    Drop-down works well, but when I will choose the option and search, I see all users.

    Is there any way to fix it? Or is it because I am taking data from other database table?

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

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

    (@helgatheviking)

    Why wouldn’t you use get_terms() to get the terms instead of a direct DB query?

    You also need to filter the sul_user_query_args as SUL won’t pick up on your meta fields automatically. If you are completely replacing the existing search input, then you need to unset the search parameter from the sul_user_query_args. If you are adding this in addition to the search parameter then you need to give the select element a unique “name” parameter so that it isn’t the same as the search input.

    Hope that helps.

    Hi moonlady,

    You have not define select option properly please use below this code

    global $wpdb;
    $qry1 = "select * from wp_terms";
    $reg1 = $wpdb->get_results($qry1);
    if(!empty($reg1))
    {
       echo '<select class="field" id="sul-s" name="as">';
         echo '<option value="'.$row1 -> name.'">'.$row1 -> name.'</option>';
       echo '</select> ';
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search by dropdown?’ is closed to new replies.