Hi @shahin999,
Thanks for the questions.
1) This is an awesome idea to add to the plugin. Actually; because of your question I just tried to add that, and it worked like a charm. So this will be available in the next release! You can then set the color / background color / bold / italic on the value object using the ‘gfexcel_value_object’-hook. When this version comes out, I’ll add the needed code to this thread.
2) Unfortunately this is not possible. You CAN add extra rows, but only AFTER the first line. This is because we separate columns and rows, to be able to manipulate both. When rendering, we first render all the columns (first row), and then we start adding the rest of the rows. I’ve looked into adding this feature, but code-wise it doesn’t make much sense to add another hook, because that would be renderer specific. And I want the renderer to just: render.
If you want to add a row after the first, you can use the gfexcel_output_rows
-hook to add an extra row to the beginning of the array.
But if I may ask, this information; is it sort of like a Description of the export? Like the description the form has for example? Because maybe, I can add a feature (with an override hook) that add’s that descriptions to the first line / column, and THEN start the output. Would that work for you? I think more people would be interested in that. Please let me know!
3) Yes this is possible by changing the metadata value. Here is a sample code:
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);
And you are right about the documentation. I try to add moest docs to the FAQ, but some things, like these hooks, are so developer specific. I figured a developer would just search through the code and locate all gf_apply_filters
functions ?? But on that note; I do have a branch on the Github project page where I’m trying to add all the documentation and hooks. It’s a slow process. Maybe one day ??
If you have any questions, please; don’t hold back!