【问题标题】:Wordpress to display custom USERMETA field on User Profile Dashboard?Wordpress 在用户配置文件仪表板上显示自定义 USERMETA 字段?
【发布时间】:2013-05-31 18:02:56
【问题描述】:
我已添加并一直在使用来自 wp_usermeta 表的 USERMETA 字段(称为:user_custom_hash)。意味着我一直是 Insert/Edit/Deleting 某处代码中的字段。
之前不需要展示出来。
所以现在..
- 如何在 Wordpress 管理仪表板的用户配置文件页面上显示此
USERMETA 字段? (我的意思是管理仪表板上的“编辑用户”页面。)
例如:
Custom Hash Key: __239cc68ba2423ddf67dcfcd4aa2fa83b__
我的意思是,在这里某处展示:
Note:
Wordpress Version currently: 3.5.0
【问题讨论】:
标签:
wordpress
customization
profile
dashboard
custom-fields
【解决方案1】:
现在可以了,我自己弄的,像这样:
add_action( 'show_user_profile', 'display_user_custom_hash' );
add_action( 'edit_user_profile', 'display_user_custom_hash' );
function display_user_custom_hash( $user ) { ?>
<h3>USERMETA Fields</h3>
<table class="form-table">
<tr>
<th><label>Custom Hash Key</label></th>
<td><input type="text" value="<?php echo get_user_meta( $user->ID, 'user_custom_hash', true ); ?>" class="regular-text" readonly=readonly /></td>
</tr>
</table>
<?php
}
- 将此 sn-p 添加到我当前主题文件夹的
functions.php 文件的底部。
注意:
在之后应该是上面的整个代码,就像以前一样,整个文件的正常?>。