meta_key和meta_value将它放在Wordpress中的数组WP_User_Query中

时间:2017-11-09 19:51:25

标签: wordpress woocommerce

我想使用函数new WP_User_Query

显示有关用户的一些信息
"umeta_id": "606",
"user_id": "18",
"meta_key": "facebook_login_data",
"meta_value": "a:24:{s:10:\"identifier\";s:16:\"XXXXX\";s:10:\"webSiteURL\";s:0:\"\";s:10:\"profileURL\";s:61:\"https://www.facebook.com/app_scoped_user_id/XXXXXX/\";s:8:\"photoURL\";s:72:\"https://graph.facebook.com/XXXXXX/picture?width=150&height=150\";s:11:\"displayName\";s:14:\"Osadchiy Yuriy\";s:11:\"description\";s:0:\"\";s:9:\"firstName\";s:5:\"Yuriy\";s:8:\"lastName\";s:8:\"Osadchiy\";s:6:\"gender\";s:4:\"male\";s:8:\"language\";s:5:\"ru_RU\";s:3:\"age\";N;s:8:\"birthDay\";i:25;s:10:\"birthMonth\";i:11;s:9:\"birthYear\";i:1988;s:5:\"email\";s:15:\"XXXX.com\";s:13:\"emailVerified\";s:15:\"XXXX.com\";s:5:\"phone\";N;s:7:\"address\";N;s:7:\"country\";N;s:6:\"region\";s:0:\"\";s:4:\"city\";N;s:3:\"zip\";N;s:9:\"job_title\";N;s:17:\"organization_name\";N;}"


如何获取用户photoURL的头像 我使用这段代码:

$args = array(
    'role' => 'Customer'
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
    echo '<p>' . $user->ID . '</p>';
    echo '<p>' . $user->display_name . '</p>';
    echo '<p>' . $user->user_email . '</p>';
    echo '<p>' . $user->billing_phone . '</p>';
    echo '<p>' . $user->billing_first_name . '</p>';
    echo '<p>' . $user->billing_last_name . '</p>';
    echo '<p>' . $user->facebook_login_data 
}
}

我很感激你的帮助。

1 个答案:

答案 0 :(得分:0)

我的决定:

$args = array(
    'role' => 'Customer'
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
    echo '<p>' . $user->ID . '</p>';
    echo '<p>' . $user->display_name . '</p>';
    echo '<p>' . $user->user_email . '</p>';
    echo '<p>' . $user->billing_phone . '</p>';
    echo '<p>' . $user->billing_first_name . '</p>';
    echo '<p>' . $user->billing_last_name . '</p>';
    if ($user->facebook_login_data){
        echo '<p>' . $user->facebook_login_data["profileURL"] .'</p>';  
    }
}
}