这就是我上述问题的答案
add_action(\'pre_user_query\',\'ap_pre_user_query\');
function ap_pre_user_query($user_search) {
$user = wp_get_current_user();
if ($user->ID!=1) { // Is not administrator, remove administrator (you can add any user-ID)
global $wpdb;
global $user_ID;
//Fetch the custom field value added in user section
$meta = get_user_meta( $user_ID );
$selected_author_id = unserialize($meta[\'select_md\'][0]);
$count = count($selected_author_id);
//to the data you got add the current user to it
$selected_author_id[$count] = $user_ID;
$store_ids = \'\';
foreach($selected_author_id as $ids){
$store_ids .= $ids.\',\';
}
$final_ids = rtrim($store_ids,\',\');
//This query will return you the result you want
$user_search->query_where = str_replace(\'WHERE 1=1\',"WHERE 1=1 AND {$wpdb->users}.ID<>1 AND {$wpdb->users}.ID IN (".$final_ids.")",$user_search->query_where);
}
}
检查以下输出