[英]How to display a grid-list of registered users under specific role with custom user meta data in WordPress?
[英]Get and display a specific Meta Data item for a current user in Wordpress
我正在尝试获取并在wordpress中为用户显示特定的元数据项。 我要获取的数据值是事件日期的值。 我尝试了以下代码,但没有运气
<?php
$user_ID = get_current_user_id();
$key = 'Event Date';
$single = true;
$user_last = get_user_meta( $user_id, $key, $single );
echo '<p>The '. $key . ' value for user id ' . $user_id . ' is: ' . $user_last . '</p>';
?>
其中“事件日期”是Ive添加到用户配置文件的自定义元字段。
请帮忙
好的,我设法弄清楚了,它可以与以下代码一起使用:
<?php
$user_id = get_current_user_id();
$key = 'Event Date';
$single = true;
$user_last = get_user_meta( $user_id, $key, $single );
echo $user_last;
?>
就使用Wordpress帮助器功能而言,我似乎找不到任何代码问题。 但是我看到您使用了错误的变量$user_ID
和$user_id
检查您的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.