我有$user = wp_get_current_user();
数组。当我打印时,它将显示为
WP_User Object
(
[data] => stdClass Object
(
[ID] => 169 // I wanted the Value of ID
[user_login] => [email protected]
[user_pass] => $P$BN2ibVoWTXB1DIsdcTnpVV03DBz8od0
[user_nicename] => madhurigmail-com
[user_email] => [email protected]
[user_url] =>
[user_registered] => 2015-11-17 09:54:57
[user_activation_key] =>
[user_status] => 0
[display_name] => Madhuri Kashid
[latitude] =>
[longitude] =>
[role] =>
)
我只想要ID的值。
我想将ID的存储值放入
$UserId
提前致谢
最佳答案
您正在获取对象而不是数组
尝试
$UserId = $user->data->ID;