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
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);