How to display custom user meta from registration in backend?

I’m considering using the hooks for the WordPress registration form to add some custom fields: https://codex.wordpress.org/Customizing_the_Registration_Form

My question is, if it’s even possible, how do I display some of these custom fields in the backend Users > All Users? For example if I have fields for ‘zip code’ and ‘address’, how would I display this data in the backend? Thanks.

2 s
2

Actually I found this to be more strait forward and simpler:

//add columns to User panel list page
function add_user_columns($column) {
    $column['address'] = 'Street Address';
    $column['zipcode'] = 'Zip Code';

    return $column;
}
add_filter( 'manage_users_columns', 'add_user_columns' );

//add the data
function add_user_column_data( $val, $column_name, $user_id ) {
    $user = get_userdata($user_id);

    switch ($column_name) {
        case 'address' :
            return $user->address;
            break;
        default:
    }
    return;
}
add_filter( 'manage_users_custom_column', 'add_user_column_data', 10, 3 );

More info for hooks for custom columns can be found here: http://tareq.wedevs.com/2011/07/add-your-custom-columns-to-wordpress-admin-panel-tables/

Leave a Comment