Quantcast
Channel: Tutorials Archives | Gravity Wiz
Viewing all articles
Browse latest Browse all 125

Gravity Forms Hook Reference

$
0
0

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 it’s 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_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_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_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_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
    • 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_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_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_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

Viewing all articles
Browse latest Browse all 125

Latest Images

Trending Articles



Latest Images