我确实为用户个人资料制作了一个自定义字段,我正在尝试检索所有用户自定义元数组但我收到错误:
$users = get_users(array(
'meta_key' => 'phone'));
foreach ($users as $value) {
$all_meta_for_user = get_user_meta( $value->ID );
$merged_array=array();
echo '<pre>';
foreach ($all_meta_for_user as $meta) {
$result = call_user_func_array("array_merge", $meta);
}
var_export($result);exit;
}
答案 0 :(得分:1)
她是解决方案
$users = get_users();
$users_array = array();
foreach ($users as $user) {
$t =get_the_author_meta( 'phone' , $user->ID );
if (strlen($t) >= 12 && strlen($t) <= 14 ) {
$users_array[]=$t;
}
}
echo "<pre>";
print_r($users_array);
echo "</pre>";