список юзеров с фильтром

Помогите реализовать на корпоративном сайте таблицу с выводом всех пользователей(сотрудников) с применением фильтра по значению meta_key = ‘people_lists_otdel’.

метод фильтраци нужен типа:

<select>
  <option>otdel1</option>
  <option>otdel2</option>
</select>

на данный момент получилось только просто вывести всех сотрудников без фильтрации:

/*
*functions.php
*/

function fb_list_authors($userlevel = 'all', $show_fullname = true) {
    global $wpdb;
    echo '
    <div id=users>

</form>
    <table border="2" align="center" cellpadding="0" cellspacing="0">
    <tr align="center" valign="middle">
    <th width="90" nowrap="nowrap" scope="col">Фото</th>
    <th width="90" nowrap="nowrap" scope="col">Имя</th>
    <th width="90" nowrap="nowrap" scope="col">Должность</th>
    <th width="90" nowrap="nowrap" scope="col">Отдел</th>
    <th width="90" nowrap="nowrap" scope="col">Кабинет</th>
    <th width="90" nowrap="nowrap" scope="col">Тел. внутр.</th>
    <th width="90" nowrap="nowrap" scope="col">Тел. гор.</th>
    <th width="90" nowrap="nowrap" scope="col">ICQ</th>
    <th width="90" nowrap="nowrap" scope="col">email</th>
  </tr>';
    $i = 0;
    while ( $i <= 10 ) {
    $userlevel = $i;
    $all = "meta_key = 'wp_user_level' AND meta_value = '$userlevel'";

    $authors = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = 'wp_user_level' AND meta_value = '$userlevel' ");
    foreach ( (array) $authors as $author ) {
    $author = get_userdata( $author->user_id );
    $userlevel = $author->wp2_user_level;
    $name = $author->nickname;
    $icq = $author->people_lists_icq;
    $tel = $author->people_lists_tel;
    $tel2 = $author->people_lists_tel2;
    $email = $author->user_email;
    $otdel = $author->people_lists_otdel;
    $doljnost = $author->people_lists_doljnost;
    $dating = $author->people_lists_dating;
    $img = get_avatar( $author->ID, 150 );
    $kabinet = $author->people_lists_kabinet;
    $id = $author->ID;
    
    if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) {
    $name = "$author->first_name $author->last_name";
    }
    
    $link =  '
        <style>
    #foto'.$id .'{ 
    display:none;     
    }
    #hideopen{
    color: #FFF;
    text-decoration: none; 
    border-bottom: 1px dashed #FFF;
    cursor: pointer;
    }
    </style>
    <script>
    function hideShowDiv'.$id.'(){ $("#foto' . $id . '").toggle("slow"); }
    </script>

    <tr align="center" valign="middle" height="15">
    <td width="150" nowrap="nowrap" ><div id="hideopen" onclick="hideShowDiv'.$id.'();">Показать/скрыть</div><div id="foto' . $id . '">' . $img . '</div></td>

    <td width="90" height="30" nowrap="nowrap" >' . $name . '</td>
    <td width="90" nowrap="nowrap" >' . $doljnost . '</td>
    <td width="90" nowrap="nowrap" >' . $otdel . '</td>
    <td width="90" nowrap="nowrap" >' . $kabinet . '</td>
    <td width="90" nowrap="nowrap" >' . $tel . '</td>
    <td width="90" nowrap="nowrap" >' . $tel2 . '</td>
    <td width="90" nowrap="nowrap" >' . $icq . '</td>
    <td width="90" nowrap="nowrap" >' . $email . '</td>
  </tr>';
    echo $link;
    }
    
    $i++;
    }
    
    echo '</table></div>';
    
    }

выводится через <?php fb_list_authors(0, TRUE); ?>
также использовал плагин пару плагинов для добавления доп полей

эх… так и никто не помог(
упросил себе задачу, но усё не могу понять как отсортировать по мета_кей выбрку:

function allusers() {
global $wpdb;


 $res = mysql_query("SELECT COUNT(*) FROM $wpdb->users");
 $row = mysql_fetch_row($res);
 $total = $row[0]; // всего записей
 echo 'Cотрудников в базе: '. $total.'</BR>
 <table border="2" align="center" cellpadding="0" cellspacing="0">
    <tr align="center" valign="middle">
    <th width="90" nowrap="nowrap" scope="col">Фото</th>
    <th width="90" nowrap="nowrap" scope="col">Имя</th>
    <th width="90" nowrap="nowrap" scope="col">Должность</th>
    <th width="90" nowrap="nowrap" scope="col">Отдел</th>
    <th width="90" nowrap="nowrap" scope="col">Кабинет</th>
    <th width="90" nowrap="nowrap" scope="col">Тел. внутр.</th>
    <th width="90" nowrap="nowrap" scope="col">Тел. гор.</th>
    <th width="90" nowrap="nowrap" scope="col">ICQ</th>
    <th width="90" nowrap="nowrap" scope="col">email</th>
  </tr>
 ';

$i = 1;
while ( $i <= $total ) {

    $user_info = get_userdata($i);
    $name = "$user_info->first_name $user_info->last_name";
    $id =  $user_info->ID;    
    $icq = $user_info->people_lists_icq;
    $tel = $user_info->people_lists_tel;
    $tel2 = $user_info->people_lists_tel2;
    $email = $user_info->user_email;
    $otdel = $user_info->people_lists_otdel;
    $doljnost = $user_info->people_lists_doljnost;
    $dating = $user_info->people_lists_dating;
    $img = get_avatar( $user_info->ID, 150 );
    $kabinet = $user_info->people_lists_kabinet;    
 
    echo '        
    <style>
    #foto'.$id .'{ 
    display:none;     
    }
    #hideopen{
    color: #FFF;
    text-decoration: none; /* Убираем подчеркивание */
    border-bottom: 1px dashed #FFF; /* Добавляем свою линию */
    cursor: pointer;
    }
    </style>
    <script>
    function hideShowDiv'.$id.'(){ $("#foto' . $id . '").toggle("slow"); }
    </script>

    <tr align="center" valign="middle" height="15">
    <td width="150" nowrap="nowrap" ><div id="hideopen" onclick="hideShowDiv'.$id.'();">Показать/скрыть</div><div id="foto' . $id . '">' . $img . '</div></td>

    <td width="90" nowrap="nowrap" >' . $name . '</td>
    <td width="90" nowrap="nowrap" >' . $doljnost . '</td>
    <td width="90" nowrap="nowrap" >' . $otdel . '</td>
    <td width="90" nowrap="nowrap" >' . $kabinet . '</td>
    <td width="90" nowrap="nowrap" >' . $tel . '</td>
    <td width="90" nowrap="nowrap" >' . $tel2 . '</td>
    <td width="90" nowrap="nowrap" >' . $icq . '</td>
    <td width="90" nowrap="nowrap" >' . $email . '</td>
  </tr>';
    $i++;
    }
    echo '</table></div>';
}
как отсортировать по мета_кей выбрку

SELECT *
FROM t1
LEFTT JOIN t2 on (key1=key2)
ORDER BY key3

http://mysql.ru/docs/man/SELECT.html
http://mysql.ru/docs/man/JOIN.html

Anonymous
Отправить
Ответ на: