Drop down filter for sorting user directory list


We need to create several drop down filters to sort the user directory. The simplest is for ‘country’ and another that lists the user levels.

I am a bit at a loss of how to start this. I found an old post, but it no longer has content: http://www.primothemes.com/forums/viewtopic.php?t=15658&p=53767#p48878

Any pointers on how to approach this would be appreciated.



Where you need that?


We need the filters in addition to the standard search on the member directory page which is created by the shortcode: [s2Member-List enable_list_search=“yes” /] [s2Member-List-Search-Box /]

Here is what I have so far:

I have a drop down list of all user levels, when a user level is selected from the dropdown I would like to automatically set the $search to that value so when search is clicked. (Or better, an automatic javascript action.)

One main problem is that ‘s2member_access_label’ does not work when used in search_columns. So far I have been unable to search users by the s2member_access_label, which is essential.

Here’s the code:

 //The search
    echo do_shortcode("[s2Member-List-Search-Box 
    placeholder='Search Members by: Name, City, Country, Keyword'

//The dropdown select ?>

<label for="_member_level">Member Level:</label><br />
<select name="_member_level" id="_member_level" class="member-level-select" >
    $lvl = array(
        '2' => 'Level 2',
        '3' => 'Level 3',
        '4' => 'Level 4',
        '5' => 'Level 5',
        '6' => 'Level 6',
        '7' => 'Level 7',
        '8' => 'Level 8',
        '9' => 'Level9',
        '10' => 'Level 10',
        '11' => 'Level 11',
    $selected = esc_attr( $lvl );
    foreach ($lvl as $code => $label) {
        echo '<option value="'.$code.'"';
        if ($selected == $code) {
            echo ' selected="selected"';
        echo '>' . $label . '</option>';

    $siteURL = get_bloginfo ( 'url' );

    //set a default value to $search. I want to update this with the selected option from the form above.    
   //Set up search_columns. We may dynamically alter this list. 
   //NOTE: s2member_access_label does not work. 
   $searchColumns = 'first_name, last_name, nickname,user_login,user_email,user_url,user_nicename,display_name, s2member_access_label,s2member_custom_field_city,s2member_custom_field_state,s2member_custom_field_country,s2member_custom_field_user_bio';
    echo do_shortcode("
    //The list shortcode. The display name links to the authors archive, which is used as a profile page. 
   //$search and $searchColumns allow us to dynamically change the search parameters
   //The list template has been customized


    /] ");

I am interested in this option. Any update to it before I try it on a staging site?