• Resolved shahin999

    (@shahin999)


    Hello,
    I need to do some modification to the excel sheet and I ask if it’s possible using hooks or so:
    1- I want to make labels font bold in Excel and add color to some columns!
    2- I want to add an extra row before the labels to contain some information!
    3- I want to render field created by (user id) as username not id!
    So if that is possible it’ll be great.
    Thanks in advance.
    Shahin

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Doeke Norg

    (@doekenorg)

    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!

    Thread Starter shahin999

    (@shahin999)

    Thanks Doeke For your help you’re really amazing ??
    For the point no. 2:
    I like to add some information like the export date, name of the form exported, and I have some user roles associated with the forms so I want to add the user role, etc..
    So if something like that is possible if I can edit the render function you tell me how or an example because the code is a bit complicated for me to know where to edit exactly ??
    Best wishes.
    Shahin

    Shahin you could check if it is possible to add that information to the form itself as a hidden or administrative field. For example with this snippet (dunno if it still works)
    https://gravitywiz.com/dynamically-populating-user-role/

    The name of the form should also be pretty easy:
    https://docs.gravityforms.com/form-object/

    That way the information will be exported by the plugin.

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @shahin999,

    Just an FYI that I released 1.5.1, containing the ability to style your cells. Checkout the updated FAQ!

    And if you need any help, please let me know!

    Closing this issue now. But please know that your second question is still on my “thinking about it”-list.

    Enjoy the update!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘need full documentation for plugin’ is closed to new replies.