I have added and been using a USERMETA field (called: user_custom_hash) from the wp_usermeta table. Means i've been Insert/Edit/Deleting the field from the code somewhere.

No needed to display it out before.
So now ..

  • how to DISPLAY this USERMETA field on the User Profile page of Wordpress Admin Dashboard? (I mean the "Edit User" page on the Admin Dashboard.)

For example:

  • Custom Hash Key: __239cc68ba2423ddf67dcfcd4aa2fa83b__

I mean, to display out at somewhere here:

enter image description here

Note:
Wordpress Version currently: 3.5.0

有帮助吗?

解决方案

It's ok now as i got it by myself, like this:

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
}
  • Add this snippet at the bottom of functions.php file of my current Theme folder.

Note:
After that entire code-above should be then, just the normal ?> for the entire file as normally as before.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top