获取自定义元所有用户Wordpress

时间:2013-11-28 19:01:24

标签: php wordpress

我确实为用户个人资料制作了一个自定义字段,我正在尝试检索所有用户自定义元数组但我收到错误:

$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;
}

1 个答案:

答案 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>";