The following snippet shows how to replace the user display name by a custom field. Just uncomment the replacement you want to keep.
If you want to show a custom user meta value, use the WordPress get_user_meta( $user_id, $key, $single ) function
function my_prefix_replace_display_name_on_leaderboards( $output, $leaderboard_id, $position, $item, $column_name, $leaderboard_table ) {
$user = get_userdata( $item['user_id'] );
// Replace the user display name by the user nickname (alias), eg: jhondoe
//$output = $user->nickname;
// Replace the user display name by the user email, eg: jhondoe@gamipress.com
//$output = $user->user_email;
// Replace the user display name by the user login (not recommended), eg: jhondoe90
//$output = $user->user_login;
// Replace the user display name by the first name, eg: Jhon
//$output = $user->first_name;
// Replace the user display name by the last name, eg: Doe
//$output = $user->last_name;
return $output;
}
add_filter( 'gamipress_leaderboards_leaderboard_column_display_name', 'my_prefix_replace_display_name_on_leaderboards', 10, 6 );