How to add custom column to Users admin panel

Hello guys! Today I am showing you how to add custom columns to user admin panel.

WordPress has 5 default columns named Username, Name, Email, Role, and posts in users like below screenshot.

Now I want to add new column with City.

Add following code in functions.php file.

function new_city_methods( $citymethods ) {
    $citymethods['text'] = 'City';
    return $citymethods;	
}
add_filter( 'user_contactmethods', 'new_city_methods', 10, 1 );
function new_custom_user_table( $column_city ) {
    $column_city['text'] = 'City';
    return $column_city;
}
add_filter( 'manage_users_columns', 'new_custom_user_table' );
function new_custom_user_table_row( $value, $column_city, $user_id ) {
    switch ($column_city) {
        case 'text' :
            return get_the_author_meta( 'text', $user_id );
        default:	
    }
    return $value;
}
add_filter( 'manage_users_custom_column', 'new_custom_user_table_row', 10, 3 );

Now you can see City field added in User contact Info. Add user city and click save button then check user admin 6th column city added in user admin panel.

You can add other custom columns in user contact info like Phone number, occupation, Zipcode, address, social information etc….

I hope this article helped you add user’s admin column. 🙂

Blog Catagory : WORDPRESS