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.
- Hooks Run for Initial Form Load
- Hooks Run on Form Submission with Validation Error
- Hooks Run on Successful Form Submission
Hooks Run for Initial Form Load
- 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_has_conditional_logic | filter more info
- gform_enqueue_scripts | action more info
- gform_enqueue_scripts_{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_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_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_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
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.
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.
Hooks Run on Form Submission with Validation Error
- 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
- gform_pre_validation | filter more info
- gform_pre_validation_{form_id} | filter more info
- 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
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.
Form Validation more info
Gravity Forms is ready to validate the submitted data based on the current $form object.
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_pre_enqueue_scripts | action more info
- gform_pre_enqueue_scripts_{form_id} | action more info
- gform_has_conditional_logic | filter more info
- gform_has_conditional_logic | filter more info
- gform_enqueue_scripts | action more info
- gform_enqueue_scripts_{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_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_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
- 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
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.
Field Markup
Hooks Run on Successful Form Submission
This scenario uses the default confirmation and the default notification.
- 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
- gform_pre_validation | filter more info
- gform_pre_validation_{form_id} | filter more info
- 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
- 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
- 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
- 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
- gform_replace_merge_tags | filter more info
- 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
- 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_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
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.
Form Validation more info
Gravity Forms is ready to validate the submitted data based on the current $form object.
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.
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.
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.
Sending Form Notifications more info
The entry has been created and saved to the database. Now Gravity Forms is ready to send notifications.
{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.
Loading Confirmation
- gform_pre_enqueue_scripts | action more info
- gform_pre_enqueue_scripts_{form_id} | action more info
- gform_has_conditional_logic | filter more info
- gform_has_conditional_logic | filter more info
- gform_enqueue_scripts | action more info
- gform_enqueue_scripts_{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_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_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
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.
Did this resource help you do something awesome with Gravity Forms?
Then you'll absolutely love Gravity Perks; a suite of 46+ essential add-ons for Gravity Forms with support you can count on.
This is a must for GF devs. Great resource. Thanks a lot for putting efforts into it.
Hi Alex,
Thanks for the kind words.
Best,
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
Hi Paco,
You can either insert the code in your function.php file or use the code snippet plugin. https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
Best,
Many thanks for this. It would be useful to include the gform_entry_field_value and gform_save_field_value in the sequence.
Hi Roger,
Thanks, we will ping our dev team to update the docs.
Best,
Hi Roger,
gform_save_field_value
is already listed in the Hooks Run on Successful Form Submission section under the Saving Fields heading.Our devs have confirmed that
gform_entry_field_value
isn’t called during any of the flows we cover with only Gravity Forms running.The gform_progressbar_start_at_zero doesn’t work anymore on Gravity Forms 2.5 and above.
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,
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?
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.
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?
I would recommend downloading the latest version of Gravity Forms and overwriting whatever version you’re currently using.
https://www.gravityhelp.com/downloads/
I’m updated to the current version. That was the first thing I tried ha.
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.
Simply a thank you, this page is so useful and I keep returning.
I’m really glad to hear it, Danny. :)
Wow, exactly what I was looking for. Wish I’d found this sooner, would have saved me a couple hours! Thanks!
Glad to help, Richard. :)
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?
Hi Sebastian, I’m assuming you’re talking about creating a custom field type for Gravity Forms? If so, I would start here: https://www.gravityhelp.com/documentation/article/gf_field/
Fantastic resource! Where do these get called?
gform_field_value gform_field_value{$parameter}
Hi Ian, those hooks are called early in the “Field Markup Loop” when dynamic population is enabled (rough example).
Hello,
Is it possible to customize the entry details section on the admin? I would like to customize the data being displayed there. Thanks!
Yes, it is possible. The “how” will depend on exactly what you want to customize.
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
This would depend on where you’re running your code and what type of code you’re running (PHP, JS?).
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
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.
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:-)
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.
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!
Hi Annie, here’s how to do this: https://gist.github.com/spivurno/ab0626e5c2fef4db1f2b
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
Hi Rob, you should be able to do something like this: http://pastie.org/10660393
Thanks David. That should work :)
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
Glad to help, Donna. :)
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.
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.
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.
Fantastic resource David. Thanks for putting the time and effort into this.
Thanks, Wil. Glad you’ve found it useful. :)