Gravity Forms Hook Reference

A reference guide for which Gravity Forms hooks are called and in what order for several typical scenarios. Provides additional information for those seeking a deeper understanding into how Gravity Forms actually works.

The goal of this reference is to give you a general idea of the order in which Gravity Forms’ hooks are called in several typical scenarios. Click on the “More Info” link that appears when you hover over a hook to reveal additional details about the hook and its purpose. Many hooks also contain a “Digging Deeper” section. These sections offer helpful advice and useful insights into how Gravity Forms works.

Toggle the filters and actions off to see the top-level flow of a Gravity Forms scenario.

  1. Hooks Run for Initial Form Load
  2. Hooks Run on Form Submission with Validation Error
  3. Hooks Run on Successful Form Submission

Hooks Run for Initial Form Load

toggle: Filters | Action

    Enqueue Scripts more info

    It all begins with WordPress' wp_enqueue_scripts action.

    This action triggers Gravity Forms' GFFormDisplay::enqueue_scripts() function. In this function, Gravity Forms determines if it needs to load any form scripts. To determine this, Gravity Forms will call the GFFormDisplay::get_embedded_forms() function. This function will search the content of all queried posts for the currrent page for the Gravity Forms shortcode (i.e. [gravityforms id="1" /]).

  • gform_form_post_get_meta | filter more info
  • gform_form_post_get_meta_{form_id} | filter more info
  • gform_pre_enqueue_scripts | action more info
  • gform_pre_enqueue_scripts_{form_id} | action more info
  • gform_has_conditional_logic | filter more info
  • gform_enqueue_scripts | action more info
  • gform_enqueue_scripts_{form_id} | action more info

    Form Markup more info

    The post content is about to be displayed and Gravity Forms' shortcode is being parsed. The GFFormDisplay::get_form() method has been called to fetch the complete form markup that will then be output to the page. All of the hooks called in this section originate from the get_form() method.

  • gform_form_args | filter more info
  • gform_disable_view_counter | filter more info
  • gform_disable_view_counter_{form_id} | filter more info
  • gform_pre_render | filter more info
  • gform_pre_render_{form_id} | filter more info
  • gform_tabindex | filter more info
  • gform_tabindex_{form_id} | filter more info
  • gform_pre_enqueue_scripts | action more info
  • gform_pre_enqueue_scripts_{form_id} | action more info
  • gform_has_conditional_logic | filter more info
  • gform_enqueue_scripts | action more info
  • gform_enqueue_scripts_{form_id} | action more info
  • gform_is_form_editor | filter more info
  • gform_is_entry_detail | filter more info
  • gform_has_conditional_logic | filter more info
  • gform_confirmation_anchor | filter more info
  • gform_confirmation_anchor_{form_id} | filter more info
  • gform_form_tag | filter more info
  • gform_form_tag_{form_id} | filter more info
    • Field Markup Loop more info

      Gravity Forms is still generating the form markup in the GFFormDisplay::get_form() method. Gravity Forms is now looping through each field on the form and generating the field markup. The following filters will be called for each field.

    • gform_is_form_editor | filter more info
    • gform_is_entry_detail | filter more info
    • gform_field_css_class | filter more info
    • gform_field_css_class_{form_id} | filter more info
    • gform_duplicate_field_link | filter more info
    • gform_delete_field_link | filter more info
    • gform_replace_merge_tags | filter more info
    • gform_field_input | filter more info
    • gform_replace_merge_tags | filter more info
    • gform_field_content | filter more info
    • gform_field_container | filter more info
    • gform_field_container_{form_id} | filter more info
    • gform_field_container_{form_id}_{field_id} | filter more info
  • gform_submit_button | filter more info
  • gform_submit_button_{form_id} | filter more info
  • gform_has_conditional_logic | filter more info
  • gform_register_init_scripts | action more info
  • gform_register_init_scripts_{form_id} | action more info
  • gform_init_scripts_footer | filter more info
  • gform_cdata_open | filter more info
  • gform_cdata_close | filter more info
  • gform_get_form_filter | filter more info
  • gform_get_form_filter_{form_id} | filter more info
  • gform_shortcode_form | filter more info

Hooks Run on Form Submission with Validation Error

toggle: Filters | Action

    Form Submission Processing more info

    The form submission process begins with WordPress' wp action. This action is triggered once WordPress is fully loaded and the WP object is setup (a.k.a. WordPress is ready to rock n' roll).

    Gravity Forms binds the GFForms::maybe_process_form() method to the wp action. This method checks the submitted data to confirm that the submission is from a Gravity Forms form. If so, Gravity Forms will call the GFFormDisplay::process_form() method to begin processing the form submission.

  • gform_form_post_get_meta | filter more info
  • gform_form_post_get_meta_{form_id} | filter more info
  • gform_pre_process | action more info
  • gform_pre_process_{form_id} | action more info
    • Form Validation more info

      Gravity Forms is ready to validate the submitted data based on the current $form object.

    • gform_pre_validation | filter more info
    • gform_pre_validation_{form_id} | filter more info
      • Field Validation Loop more info

        Gravity Forms is validating the submitted value for each field in the current form. The following hooks will be called for each field unless the field is hidden via conditional logic or is an Admin Only field.

      • gform_trim_input_value | filter more info
      • gform_field_validation | filter more info
      • gform_field_validation_{form_id} | filter more info
      • gform_field_validation_{form_id}_{field_id} | filter more info
    • gform_validation | filter more info
    • gform_validation_{form_id} | filter more info
  • gform_post_process | action more info
  • gform_post_process_{form_id} | action more info

    Enqueue Scripts more info

    Not much changes when enqueueing scripts for a form with a validation error. The enqueuing process still kicks off with WordPress' wp_enqueue_scripts action.

    This action triggers Gravity Forms' GFFormDisplay::enqueue_scripts() function. In this function, Gravity Forms determines if it needs to load any form scripts. To determine this, Gravity Forms will call the GFFormDisplay::get_embedded_forms() function. This function will search the content of all queried posts for the currrent page for the Gravity Forms shortcode (i.e. [gravityforms id="1" /]).

  • gform_pre_enqueue_scripts | action more info
  • gform_pre_enqueue_scripts_{form_id} | action more info
  • gform_has_conditional_logic | filter more info
  • gform_enqueue_scripts | action more info
  • gform_enqueue_scripts_{form_id} | action more info

    Form Markup more info

    The post content is about to be displayed and Gravity Forms' shortcode is being parsed. The GFFormDisplay::get_form() method has been called to fetch the complete form markup that will then be output to the page. All of the hooks called in this section originate from the get_form() method.

  • gform_form_args | filter more info
  • gform_disable_view_counter | filter more info
  • gform_disable_view_counter_{form_id} | filter more info
  • gform_pre_render | filter more info
  • gform_pre_render_{form_id} | filter more info
  • gform_tabindex | filter more info
  • gform_tabindex_{form_id} | filter more info
  • gform_pre_enqueue_scripts | action more info
  • gform_pre_enqueue_scripts_{form_id} | action more info
  • gform_has_conditional_logic | filter more info
  • gform_enqueue_scripts | action more info
  • gform_enqueue_scripts_{form_id} | action more info
  • gform_is_form_editor | filter more info
  • gform_is_entry_detail | filter more info
  • gform_has_conditional_logic | filter more info
  • gform_confirmation_anchor | filter more info
  • gform_confirmation_anchor_{form_id} | filter more info
  • gform_form_tag | filter more info
  • gform_form_tag_{form_id} | filter more info
  • gform_validation_message | filter more info
  • gform_validation_message_{form_id} | filter more info
    • Field Markup

    • gform_trim_input_value | filter more info
    • gform_is_form_editor | filter more info
    • gform_is_entry_detail | filter more info
    • gform_field_css_class | filter more info
    • gform_field_css_class_{form_id} | filter more info
    • gform_duplicate_field_link | filter more info
    • gform_delete_field_link | filter more info
    • gform_replace_merge_tags | filter more info
    • gform_field_input | filter more info
    • gform_replace_merge_tags | filter more info
    • gform_field_content | filter more info
    • gform_field_container | filter more info
    • gform_field_container_{form_id} | filter more info
    • gform_field_container_{form_id}_{field_id} | filter more info
  • gform_submit_button | filter more info
  • gform_submit_button_{form_id} | filter more info
  • gform_has_conditional_logic | filter more info
  • gform_register_init_scripts | action more info
  • gform_register_init_scripts_{form_id} | action more info
  • gform_init_scripts_footer | filter more info
  • gform_cdata_open | filter more info
  • gform_cdata_close | filter more info
  • gform_get_form_filter | filter more info
  • gform_get_form_filter_{form_id} | filter more info
  • gform_shortcode_form | filter more info

Hooks Run on Successful Form Submission

This scenario uses the default confirmation and the default notification.

toggle: Filters | Action

    Form Submission Processing more info

    The form submission process begins with WordPress' wp action. This action is triggered once WordPress is fully loaded and the WP object is setup (a.k.a. WordPress is ready to rock n' roll).

    Gravity Forms binds the GFForms::maybe_process_form() method to the wp action. This method checks the submitted data to confirm that the submission is from a Gravity Forms form. If so, Gravity Forms will call the GFFormDisplay::process_form() method to begin processing the form submission.

  • gform_form_post_get_meta | filter more info
  • gform_form_post_get_meta_{form_id} | filter more info
  • gform_pre_process | action more info
  • gform_pre_process_{form_id} | action more info
    • Form Validation more info

      Gravity Forms is ready to validate the submitted data based on the current $form object.

    • gform_pre_validation | filter more info
    • gform_pre_validation_{form_id} | filter more info
      • Field Validation Loop more info

        Gravity Forms is validating the submitted value for each field in the current form. The following hooks will be called for each field unless the field is hidden via conditional logic or is an Admin Only field.

      • gform_trim_input_value | filter more info
      • gform_field_validation | filter more info
      • gform_field_validation_{form_id} | filter more info
      • gform_field_validation_{form_id}_{field_id} | filter more info
    • gform_validation | filter more info
    • gform_validation_{form_id} | filter more info
  • gform_pre_submission | action more info
  • gform_pre_submission_{form_id} | action more info
  • gform_pre_submission_filter | filter more info
  • gform_pre_submission_filter_{form_id} | filter more info
    • Saving Entry more info

      Great news! The submission has been successfully validated. Gravity Forms is going to save the submission as an $entry object in the database.

    • gform_entry_id_pre_save_lead | filter more info
    • gform_entry_id_pre_save_lead_{form_id} | filter more info
    • gform_is_form_editor | filter more info
    • gform_is_entry_detail | filter more info
    • gform_currency | filter more info
      • Saving Fields more info

        The basic entry details have been saved to the database (e.g. "form_id", "ip", "source_url", "date_created", "user_agent", "currency", "created_by"). Gravity Forms will now loop through each field (and each input for multi-input fields) and save them individually to entry. All of these hooks are originate from the GFFormsModel::save_input() method.

      • gform_trim_input_value | filter more info
      • gform_is_form_editor | filter more info
      • gform_is_entry_detail | filter more info
      • gform_allowable_tags | filter more info
      • gform_allowable_tags_{form_id} | filter more info
      • gform_save_field_value | filter more info
  • gform_get_input_value | filter more info
  • gform_entry_meta | filter more info
  • gform_entry_is_spam | filter more info
  • gform_entry_is_spam_{form_id} | filter more info
  • gform_entry_created | action more info
  • gform_entry_post_save | filter more info
  • gform_entry_post_save_{form_id} | filter more info
  • gform_disable_post_creation | filter more info
  • gform_disable_post_creation_{form_id} | filter more info
    • Sending Form Notifications more info

      The entry has been created and saved to the database. Now Gravity Forms is ready to send notifications.

    • gform_disable_notification | filter more info
    • gform_disable_notification_{form_id} | filter more info
    • gform_notification | filter more info
    • gform_notification_{form_id} | filter more info
    • gform_pre_replace_merge_tags | filter more info
    • gform_replace_merge_tags | filter more info
      • {all_fields} more info

        Since the {all_fields} merge tag is the most popular Gravity Forms merge tag, I wanted to cover its usage in notifications. At this point, Gravity Forms is processing the "message" property of the current notification. The default notification contains the {all_fields} merge tag.

        Note: the gform_replace_merge_tags filter is called after the {all_fields} markup has been generated. It is excluded here for the sake of orginzation.

      • gform_get_field_value | filter more info
      • gform_merge_tag_filter | filter more info
      • gform_email_background_color_label | filter more info
      • gform_email_background_color_data | filter more info
    • gform_enable_shortcode_notification_message | filter more info
    • gform_pre_send_email | filter more info
    • gform_after_email | action more info

      Loading Confirmation

    • gform_confirmation_anchor | filter more info
    • gform_confirmation_anchor_{form_id} | filter more info
    • gform_pre_replace_merge_tags | filter more info
    • gform_replace_merge_tags | filter more info
    • gform_confirmation | filter more info
    • gform_confirmation_{form_id} | filter more info
  • gform_after_submission | action more info
  • gform_after_submission_{form_id} | action more info
  • gform_post_process | action more info
  • gform_post_process_{form_id} | action more info

    Enqueue Scripts more info

    It all begins with WordPress' wp_enqueue_scripts action.

    This action triggers Gravity Forms' GFFormDisplay::enqueue_scripts() function. In this function, Gravity Forms determines if it needs to load any form scripts. To determine this, Gravity Forms will call the GFFormDisplay::get_embedded_forms() function. This function will search the content of all queried posts for the currrent page for the Gravity Forms shortcode (i.e. [gravityforms id="1" /]).

  • gform_pre_enqueue_scripts | action more info
  • gform_pre_enqueue_scripts_{form_id} | action more info
  • gform_has_conditional_logic | filter more info
  • gform_enqueue_scripts | action more info
  • gform_enqueue_scripts_{form_id} | action more info

    Form Markup more info

    Gravity Forms is ready to render the form markup. The markup for a successful submission is dictated by the confirmation. The following hooks will be executed only for a "Text"-type confirmation. Page and Rediect URL confirmations will simply redirect to the designated URL.

  • gform_form_args | filter more info
  • gform_disable_view_counter | filter more info
  • gform_disable_view_counter_{form_id} | filter more info
  • gform_pre_render | filter more info
  • gform_pre_render_{form_id} | filter more info
  • gform_tabindex | filter more info
  • gform_tabindex_{form_id} | filter more info
  • gform_pre_enqueue_scripts | action more info
  • gform_pre_enqueue_scripts_{form_id} | action more info
  • gform_has_conditional_logic | filter more info
  • gform_enqueue_scripts | action more info
  • gform_enqueue_scripts_{form_id} | action more info
  • gform_is_form_editor | filter more info
  • gform_is_entry_detail | filter more info
  • gform_progressbar_start_at_zero | filter more info
  • gform_shortcode_form | filter more info

Comments

  1. Paco
    Paco July 13, 2022 at 9:02 am

    I know it is a stupid questions, but where I need to include these hooks? Using the add-on “code snippet in WordPress is a good way? Which are the other? Thanks a lot in advance

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff May 5, 2021 at 6:12 am

      Hi Bryan,

      Thanks for bringing this to our attention. We’re currently updating our documents to reflect Gravity Forms 2.5, so we’ll be adding this to the list.

      Best,

  2. chuteo007
    chuteo007 March 16, 2020 at 11:57 pm

    Hi David, How can I use jQuery to change $field->visibility, gwwordcount_max_word_count… when I click radio button? I can change with query string by using hook pre_render but cannot with js?

    Reply
  3. Jeffrey Moody
    Jeffrey Moody February 5, 2018 at 7:54 pm

    Hey David. Newbie here trying to make my bowling tournament’s registration site usable.

    Brief version of what I have: A multipage gravityform that allows editing of submitted entries. I have it so that the first team member creates a user (team name) and a password. They then complete as much of the registration form as possible. Normally this means that they fill in their personal information (pages 2-5 each contain data required for one bowler). So, the first bowler registers as one of those bowlers and then submits the form. They then send the login info to the rest of their team and each team member goes in and completes their page on the registration.

    Issue: I need to have it so that once a bowler registers, the data on that page is marked as read only (not disabled). So, in theory, what I would have is a checkbox, dropdown or radio button asking if the bowler is finished entering their personal data. If the answer is “yes” then when the form is submitted, the data on that specific page is made read only. However, the remaining pages are still editable by the other team members.

    So, if the first person registers as bowler 4 (page 5) then after the form is submitted page 5 is read only from then on. Then when the next bowler goes in to register and uses page 2, then after they submit the form, pages 2 and 5 are now read only.

    Is there a hook or process that would allow me to do this? I asked gravityforms support and they just said that this is not a feature that gravityforms offers.

    Any help is greatly appreciated.

    Reply
  4. Tyrel Olsen
    Tyrel Olsen March 8, 2017 at 6:43 pm

    So I’m having issues getting and field validation to work and noticed my Gravity Forms form_display.php doesn’t contain GFFormDisplay::validate() anywhere inside of it. Where and how should I add it? Does it work for everyone else?

    Reply
    1. David Smith
      David Smith Staff March 9, 2017 at 9:13 am

      I’m running the latest version as well and the GFFormDisplay::validate() method is there for me. I’d reach out to Gravity Forms support.

  5. Sebastian
    Sebastian November 3, 2016 at 4:40 pm

    Hey. Nice work man :) I want to create a custom field for address. I do not now what is the best? I have been looking for filters to change content in the admin site but i am not sure witch filters should i use to change whole field object. And how to get access to this object in my functions? And also if is necessary to use javascript?

    Reply
  6. Jm
    Jm May 28, 2016 at 7:57 pm

    Hello,

    Is it possible to customize the entry details section on the admin? I would like to customize the data being displayed there. Thanks!

    Reply
    1. David Smith
      David Smith Staff May 29, 2016 at 8:30 pm

      Yes, it is possible. The “how” will depend on exactly what you want to customize.

  7. simon buerman
    simon buerman April 29, 2016 at 6:09 pm

    Hello i would like to know if it exist a hook to get the current page id and the last page id of a multipage form . i would like to do somthing like that:

    numberofpage=last_page_id – first_page_id pourcentage_page=100/numberofpage

    for(i=first_page_id,i<=last_page_id,i++){ pourcentage_page_specific=pourcentage_page*i } but i don’t see how retrieve the id of the last_page dynamicly

    Reply
    1. David Smith
      David Smith Staff April 29, 2016 at 10:05 pm

      This would depend on where you’re running your code and what type of code you’re running (PHP, JS?).

    2. buerman
      buerman April 30, 2016 at 9:45 am

      I would want to make a percentage of submission of the form, on the same principle as a progress bar but without bar because I want to make that in the form of stage.

      I believe that the JS is more adapted but the place it is exactly the problem, I am not too much on to know where to put this code

    3. David Smith
      David Smith Staff May 2, 2016 at 11:00 pm

      Hey Simon, I think this question would be better directed to Gravity Forms support. I’m just not sure what you’re after and they have a much larger support team for fielding general Gravity Forms questions.

    4. buerman
      buerman May 3, 2016 at 6:56 am

      I have already asked the question to the support of gravity form but the only answer to which I was entitled it was called on to a developer freelance “you will agree that appeal to a developer freelance to make a simple function, it is a high price to pay:-)

    5. David Smith
      David Smith Staff May 3, 2016 at 8:44 am

      Hi Simon, I understand. To get the current page, you could use a hook like this one:

      https://www.gravityhelp.com/documentation/article/gform_page_loaded/

      To get the total page count you could use jQuery to find all the .gform_page elements and count their length.

      var pageCount = jQuery( ‘.gform_page’ ).length;

      The code could either go in an HTML field in your form (wrapped in <script> tags) or in your theme’s JS file.

  8. Annie
    Annie January 10, 2016 at 10:35 pm

    Hi David!

    I have a form that is loaded on a fancybox iframe, and on “Confirmation” I have it set to redirect to the page that was just created. Do you know if it would be possible to use a hook to set the target=”_parent” so the new page doesn’t load inside the iframe?

    Thanks in advance!

    Reply
  9. Rob
    Rob December 29, 2015 at 8:36 pm

    Hi David,

    Do you know if there is a way to target a form confirmation/notification by name as opposed to ID? The Gravity Forms documentation gives an example which targets form with ID 6:

    add_filter( ‘gform_confirmation_6’, ‘custom_confirmation’, 10, 4 );

    But this means the ID’s of live forms have to match the ID’s of development forms, which for me is not always the case.

    Thanks in advance, Rob

    Reply
  10. Donna McMaster
    Donna McMaster September 25, 2015 at 12:18 am

    Thanks so much! Gravity Forms reworked their documentation structure so that it’s even less useful than before. You just saved me an hour of frustration trying to find the right hook!

    Cheers! Donna

    Reply
  11. P.G. Ros
    P.G. Ros August 18, 2015 at 5:34 am

    Thank you so much for writing this article, I asked for this at gravirty support and you took the liberty of writing it! This is incredibly useful.

    Reply
  12. Chris Edwards
    Chris Edwards August 10, 2015 at 3:16 pm

    Using these, how can I put the Total price into the sidebar. I have it at the bottom of my form currently, but, would love to move it to the sidebar instead.

    Reply
    1. David Smith
      David Smith Staff August 20, 2015 at 8:40 am

      You could use jQuery to move the field on page load. Or CSS to style it so it appears in the sidebar. Or if you want to get really fancy, you could write a custom widget that mimics the value from the form itself.

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.