Get user from user meta_value array in WordPress

Opsional asked
php arrays wordpress
via

i need help with WordPress to get user use get_user(); If user meta_value not array i can handle it, but now user meta_value is array.

$array_user_meta = array(
    'user_id' => 100,
    'user_facebook_id' => 58977667867887,
);

$wp_users = get_users(array(
    'meta_key'     => 'user_biodata',
    'meta_value'   => 'how to access user_facebook_id,
    'number'       => 1,
    'count_total'  => false,
    'fields'       => 'id',
));

Thank you.,

=====================

Edited;

The $array_user_meta only sample, not actual array to get value 'user_facebook_id', so can’t get value like $array_user_meta['user_facebook_id'];

I case, this use in facebook user login auth., so i want if user already registered they automatic login.

Now, the user_facebook_id stored as array in user_biodata. so can’t passed meta_key (user_biodata) and meta_value (facebook_id) directly:

$wp_users = get_users(array(
    'meta_key'     => 'user_biodata',
    'meta_value'   => 'can't passed user_facebook_id because stored in array',
    'number'       => 1,
    'count_total'  => false,
    'fields'       => 'id',
));


Answer
via

You can access the facebook ID using the associative array key.

<?php
$user_facebook_id = $array_user_meta['user_facebook_id'];

Referencing: http://php.net/manual/en/language.types.array.php

Share This
Posted in: