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.

Related posts

2 comments

  1. 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/

  2. To display the user meta data in the User’s page, you need the filters manage_users_custom_column and manage_users_columns: Sortable Custom Columns in User Panel (users.php)?

    And to add the fields in the User/Profile pages, the following (from Checkboxes in registration form):

    // PROFILE
    add_action( 'show_user_profile', 'user_field_wpse_87261' );
    add_action( 'personal_options_update', 'save_profile_fields_87261' );
    
    // USER EDIT
    add_action( 'edit_user_profile', 'user_field_wpse_87261' );
    add_action( 'edit_user_profile_update', 'save_profile_fields_87261' );
    

Comments are closed.