Oh I’m so sorry, I misunderstood your question. I thought you WANTED the ID, but got the username instead, but I now see it’s the other way around.
That is actutally pretty easy. Even more so because this question was already asked before, but the title of that issue was not really explicit about that. This one is, so here is the code you need to add in your functions.php
.
add_filter('gfexcel_meta_value_created_by', function ($value) {
if (!is_numeric($value) || (!$user = get_userdata($value))) {
// no userid or no user, return default.
// also, get_userdata caches the results of this query, so there is no extra memory overhead
return $value;
}
//return username from user object
return $user->nickname; //or use 'display_name'
});
//We also need this, because created_by is a number field by default, and we need it to be a string.
add_filter('gfexcel_value_type', function ($type, $field) {
if ($field->id !== 'created_by') {
return $type;
}
return 'string';
}, 10, 2);
Hope this helps!