Search code examples
wordpresscustomizationprofiledashboardcustom-fields

Wordpress to display custom USERMETA field on User Profile Dashboard?


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


Solution

  • 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.