EDIT: My original solution is below, but Sumit alerted me in the comments to the existence of the get_avatar filter. I've posted an additional answer that shows how to implement that option as well.
Yes, you can do this.
The columns displayed in any of these 'list tables' in Wordpress admin are filterable - so using a custom function in your theme's functions.php
, you can remove columns or add your own.
This function will allow you to both remove the default column and add a custom one:
add_filter("manage_users_columns", "wpse_228870_custom_user_avatar");
function wpse_228870_custom_user_avatar($columns){
$columns =
array_slice($columns, 0, 1) // leave the checkbox in place (the 0th column)
+ array("custom_avatar" => "") // splice in a custom avatar column in the next space
+ array_slice($columns, 1) // include any other remaining columns (the 1st column onwards)
;
return $columns;
}
There's many ways you can do that but in this I've basically just taken the $columns
array and massaged it to stick your custom avatar in at the second position. You can use any PHP array function to do whatever you want to these columns.
Next, we need to tell Wordpress what to display in that custom_avatar
column:
add_filter("manage_users_custom_column", "wpse_228870_custom_user_avatar_column", 10, 3);
function wpse_228870_custom_user_avatar_column($output, $column_name, $user_id){
// bow out early if this isn't our custom column!
if($column_name != "custom_avatar"){ return $output; }
// get your custom field here, using $user_id to get the correct one
// ........
// enter your custom image output here
$output = '<img src="image.png" width="50" height="50" />';
return $output;
}
If the image doesn't come out at the right dimensions or isn't styled appropriately, you can add styles to Wordpress admin if you want to have more control over how the columns and their contents are sized.
You can also read more about the two filters I used in the Wordpress documentation - manage_users_columns is on the Codex and manage_users_custom_column is on the newer code reference. Similar filters exist for any of the other tables, such as posts and pages.