我正在使用高级自定义字段插件为用户配置文件添加自定义字段,并使用简单的用户列表插件在站点前端显示用户列表。
我需要通过一些选项通过自定义搜索筛选用户列表:城市、社区和课程大学。
请参见此屏幕截图中如何使用它的示例:
See the screenshot of user profile displayed on the frontend
我创建了一个表单,它提供了下拉字段,允许选择城市、社区和课程,但过滤不起作用。我需要根据搜索词显示多个用户,而不是像插件提供的那样搜索单个用户。
我的问题是:如何传递值数组要搜索用户并返回列表?
下面是我添加到城市、社区和球场搜索中的代码示例,但搜索不起作用。我对PHP知之甚少。
if ($_GET["FormOfSearch"]){ // if search form is submitted
if(isset($_GET["nome_of_city"]))
{
$select_city = $_GET["name_of_city"];
}else{
$select_city = "";
}
if(isset($_GET[\'name_of_neighborhood\']))
{
$select_neighborhood = $_GET[\'name_of_neighborhood\'];
}else{
$select_neighborhood = \'\';
}
if(isset($_GET[\'name_of_course\'])){
$select_course = $_GET[\'name_of_course\'];
}else{
$select_course = \'\';
}
$list_of_id = "SELECT user_id FROM $wpdb->usermeta WHERE (meta_value = \'$select_city\') AND user_id IN (SELECT user_id FROM $wpdb->usermeta WHERE (meta_value= \'$select_neighborhood\')) AND user_id IN (SELECT user_id FROM $wpdb->usermeta WHERE (meta_value = \'$select_course\'))";
// Below, the array provided by plugin, I add the list of ID searched
// Generate the query based on search field
$args2 = array(
\'include\' => \'*\' . $list_of_id . \'*\',
\'number\' => $number,
\'orderby\' => $orderby,
\'order\' => $order
);