这项工作:
$WhoIsUser = get_users(
array(
\'meta_key\' => \'deviceid\',
\'meta_value\' => \'45545\'
)
);
这将从users表中返回该用户的整行。如果这样打印出来:
echo \'<pre>\'
echo print_r($WhoIsUser, TRUE);
echo \'</pre>\'
您可以获得:
Array
(
[0] => WP_User Object
(
[data] => stdClass Object
(
[ID] => 123
[user_login] => userman
[user_pass] => $P$mBH8dpvhJD5xN8pk.
[user_nicename] => usermans
[user_email] => [email protected]
[user_url] =>
[user_registered] => 2020-05-11 14:36:24
[user_activation_key] => 157784:Fj8SR051xbzUVMpAFcYI0
[user_status] => 0
[display_name] => J B Gomez
)
[ID] => 123
[caps] => Array
(
[subscriber] => 1
)
and so on....
要仅访问ID,我写了以下内容:
$WhoIsUser[0]->ID;