您需要向用户列表屏幕添加自定义列,如下所示:
// Add a custom user column called Photo with a column key of user_photo
// and re-arrange the columns array so our new column appears first.
function add_user_columns( $defaults ) {
$new_order = array();
foreach ( $defaults as $key => $title ) {
if ( \'username\' === $key ) {
$new_order[\'user_photo\'] = __( \'Photo\', \'your_textdomain\' );
}
$new_order[ $key ] = $title;
}
return $new_order;
}
add_filter( \'manage_users_columns\', \'add_user_columns\', 15 );
// Add data to our user column, specifically in your case
// get the photo from user meta
function add_custom_user_columns( $value, $column_name, $id ) {
if ( \'user_photo\' === $column_name ) {
// replace `$meta_key` with the relevant key that holds the photo
return get_user_meta( $id, $meta_key, true );
}
}
add_action( \'manage_users_custom_column\', \'add_custom_user_columns\', 15, 3 );