0

I have used few custom fields while new user registering, I want those custom fields to be showed in the User table in Admin along with Username / Name / Email / Role / Custom field

1 Answer 1

1

You can use the bellow function for adding custom column to users table:

function modify_user_columns($column_headers) {
    $column_headers['custom_field'] = 'Custom field';
    return $column_headers;
}
add_action('manage_users_columns', 'modify_user_columns');

function custom_admin_css() {
    echo '<style>
    .column-custom_field {width: 8%}
    </style>';
}
add_action('admin_head', 'custom_admin_css');

function user_posts_count_column_content($value, $column_name, $user_id) {
    if ( 'custom_field' == $column_name ) {
        return 'Value';
    }

    return $value;
}
add_action('manage_users_custom_column', 'user_posts_count_column_content', 10, 3);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.