Hi @paolonuzzi86,
Well actually, the plugin SHOULD render the user id under created_by, and not the username. The user id is also the data as saved in the database. Do you perhaps have another plugin active for Gravity Forms? These have the power to influence the final output, so it can be that such a plugin is changing the value.
And being able to update the final value is actually something I want to keep in there, to make the plugin extendable. You should probably look for a hook attached to gform_export_field_value in combination with created_by.
Let me know if this helps? Thanks!
Thanks for the reply, so you can not enter the username (not ID) under the “created by” entry?
Did I get it right?
Thanks again
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!
mythical, really thank you:))))