PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Hide certain fields or data after being submitted using gform_after_submission

  1. Gaslight
    Member

    Suppose I have some field I don't want to pass to an external application how should i filter those fields altogether (id, label and value(s)) with gform_after_submission?

    (in my case 3rd party app is WooCommerce... when I use gravity forms to pass product options, certain hidden fields which I use to activate some conditional logic appear on the cart: I wish to remove those, while retaining their conditional logic usefulness while forum being filled)

    a related question, can I use gform_after_submission to change appearance of data being passed? I have three dropdowns: Day, Month, Year. They're passed separately because I need them separately for some conditional logic. However, in the final submitted forms would it be possible to pass them as a single well formatted string or even better, in my case, a propert date?

    Posted 12 years ago on Sunday February 19, 2012 | Permalink
  2. If you are using the Gravity Forms Extension for WooCommerce you may want to discuss this with their developers as i'm not familiar enough with what is going on under the hood with that extension to be able to provide you with guidance on how to filter what is passes to the WooCommerce cart.

    If what you want to do is not store the value of some fields that are used solely for conditional logic purposes then you can use ANOTHER hook, the gform_pre_submission hook, to execute custom code that will set the value of the field you want to update so that it is empty.

    The gform_pre_submission hook is triggered AFTER validation has occurred but BEFORE notifications and the entry itself is created. You an find documentation on the gform_pre_submission hook here:

    http://www.gravityhelp.com/documentation/page/Gform_pre_submission

    But please note, the hook is just a code hook... by itself it doesn't implement any code or customizations. You have to write the custom PHP necessary to accomplish what you want to do as part of the code that you use with that hook.

    As for your question regarding your date date fields...

    The gform_after_submission hook just gives you access to the entry object to both get data from the entry object and update data in the entry object. It doesn't send data to 3rd party applications, whatever custom PHP you write is what sends data to 3rd party applications. So if you don't want to send a particular field to the 3rd party application then don't write the code to do so.

    If you want to pass your three drop downs as a single date value then you would write custom PHP using the gform_after_submission hook to get the value of those fields from the entry object and then combine them into a single value that you then pass to another application OR store as the value of a field in the entry object and update/replace an existing value.

    You can do whatever you want with the gform_after_submission hook as long as you know how to do what you want to do using PHP.

    Posted 12 years ago on Tuesday February 21, 2012 | Permalink
  3. Gaslight
    Member

    Understood, thanks Carl

    however, is there any guideline I can use to tweak a form output by php?

    ie, suppose I want to filter one field value, since field ID is known, ie... even if we don't know how WooCommerce handles a gravity form, if the data WooCommerce is received is filtered in the first place, like certain fields never exists, then maybe it doesn't matter what WooCommerce does with the rest of the form right?

    thank you

    Posted 12 years ago on Tuesday February 21, 2012 | Permalink
  4. No, there are no guidelines.

    The hooks and filters themselves don't do anything. They just allow you to execute your own custom PHP at certain points in Gravity Forms.

    It's all standard PHP. You can do whatever you want with PHP. But you have to know how to do what you want to do with PHP.

    If you want to filter what values WooCommerce gets then you'd have to customize the WooCommerce Gravity Forms Extension itself, not Gravity Forms.

    Either that or as I mentioned above, you'd have to NOT store the value of the field at all by using the gform_pre_submission to set it's value so that it is empty.

    I'm going to repeat something I said in one of the other threads regarding hooks, filters and customizations...

    From a form processing standpoint, ANYTHING is possible with Gravity Forms. The hooks and filters that are in place make any kind of customization that you'd like to happen after the form is submitted possible. However, you have to be able to write the custom PHP to make it possible.

    Gravity Forms only provides the hooks and filters necessary to allow you to attach your own custom code to key points in the form processing life cycle. We explain in the documentation when each hook is triggered and what each hook does. What you do with those hooks and filters is entirely up to you and/or your developer.

    Posted 12 years ago on Tuesday February 21, 2012 | Permalink
  5. Gaslight
    Member

    Ok Carl I understood now

    I've checked again the GF documentation for the function we are discussing now and there's an example how to change value of a specific field:

    add_action("gform_pre_submission_7", "pre_submission_handler");
    function pre_submission_handler($form){
        $_POST["input_14"] = "new value for field 14";
    }

    I think I can figure out how to filter the ID of the field I want to get rid of from $_POST

    sorry for the previous misunderstanding

    Posted 12 years ago on Tuesday February 21, 2012 | Permalink