【发布时间】:2017-06-17 11:51:30
【问题描述】:
我使用此代码在 wp 中为管理员和订阅者提供支持的每个用户配置文件显示用户注册日期。
add_action( 'show_user_profile', 'display_user_custom' );
add_action( 'edit_user_profile', 'display_user_custom' );
function display_user_custom( $user ) { ?>
<h3>Registration</h3>
<table class="form-table">
<tr>
<th><label>Registered Since</label></th>
<td><?php $udata = get_userdata( $user-ID );
$registered = $udata->user_registered; echo date( "d M Y", strtotime( $registered ) ); ?></td>
</tr>
</table>
<?php
}
它可以工作,但日期始终来自用户 ID 1,$user-ID 始终为 1。我已经“在私人浏览器中”使用多个帐户登录进行了测试。
【问题讨论】: