无法在WP中获取usermeta描述变量

时间:2014-07-24 04:07:18

标签: php wordpress

访问worpress中当前用户的usermeta描述字段对我很挑剔。我使用描述作为生物领域。这是我在下面的内容。显示名称部分工作正常,但与获取描述无关。我知道$ bio [0] - >描述不正确,但这是我在发布之前尝试的最后一件事。也许我只是累了...

<?php 
global $current_user;
get_currentuserinfo();
$bio = get_usermeta( $current_user, $description ); 

echo 'Your Name: ' . $current_user->display_name . "\n";
?>

Your Bio: <?php echo $bio[0]->description ?>

1 个答案:

答案 0 :(得分:0)

明确指出manual

<?php get_usermeta( $userid, $metakey ); ?>

您需要使用$userid(用户ID)和特定$metakey来提供。

样本用法:

echo $bio = get_usermeta($current_user->id, 'description');

仅供参考:在manual中也说这个函数是deprecated

请改为尝试:

echo $bio = get_user_meta($current_user->id, 'description');
相关问题