0
我正在做一个解决方法,使用Cimy用户额外字段来筛选结果(我无法做查询等等)。所以我创建了一个下拉表单,并使用选定的字段/值来过滤要显示的用户。重复多次相同的长码
这里是WordPress用户的插件功能,用于显示用户去“名单”
function get_user_listing($curauth) {
global $post;
$concat = wpu_concat_single();
$homeuni=get_cimyFieldValue($curauth->ID,'homeuni');
$selectedhomeuni = $_GET['homeunis']; // Key that gets one dropdown value
$selectedhostuni = $_GET['hostunis']; // Key that gets the other dropdown value
if($selectedhomeuni == "all" && $selectedhostuni == "all") {
// Here goes the bunch of repeated code
}
elseif($selectedhomeuni != "all" && $selectedhostuni == "all") {
// Here goes the bunch of repeated code again
}
elseif($selectedhomeuni == "all" && $selectedhostuni != "all") {
// Here goes the bunch of repeated code again
}
elseif($selectedhomeuni != "all" && $selectedhostuni != "all") {
// Here goes the bunch of repeated code again
}
return $html;
}
而且here (Pastebin) is the long code to be repeated。与“,”,\“和$。
我试过函数,键和包含来调用该代码,但他们都没有正常工作。我甚至不确定在我尝试时可以做到这一点“简单”。我根本不是专家。
非常感谢。
有一个函数,并从pastebin中判断出一个数组映射 – mario
如果使用'include',错误信息是什么? – bansi
@mario我会看看它,虽然它不会 – antonio1475