Support

Account

Home Forums General Issues Form Processing Hook Chart

Solved

Form Processing Hook Chart

  • Has anyone created a chart for Form processing?

    A list of the order in which all of the hooks are called?

  • The actions/filters are not listed in the docs in the order they fire and some of the descriptions are ambiguous.

    For example, does “acf/init” fire after everything is done? All fields are rendered? Is it literally the last action to fire?

  • This is my guess on order when creating/editing a post:

    • acf/input/admin_enqueue_scripts
    • acf/input/admin_head
    • acf/load_field
    • acf/load_value
    • acf/prepare_field
    • acf/render_field
    • acf/init
    • acf/input/form_data
    • acf/upload_prefilter
    • acf/validate_attachment
    • acf/update_value
    • acf/validate_value
    • acf/validate_save_post
    • acf/save_post
  • I don’t know what order they all fire, but, for example, acf/init fires during the WP init action. This is probably the earliest of them all. For the rest, most of them are called during the WP action or filter of the same name, like admin enqueue scripts, admin_head.

    During form processing, that is saving values, some of them will not be run at all, these include acf/prepare_field and acf/render_field. The first when is run before a field is rendered and the second is run to render the field. Since there’s no rendering of fields during the save process they would not be called.

    acf/load_field, acf/load_value, acf/validate_value, acf/update_value are all run on each field where the documentation mentions them. I do not believe that acf/load_value is called at all during form processing, saving of a value. The only exception to this would be if you have added an acf/save_post filter and you’re getting the values of the fields for some reason.

    acf/save_post is run after WP inserts or updates a post. This could also run after WP inserts or updates a term or user. This is also run when an options page is being saved, but since there is not WP object envolved here I wouldn’t be sure.

    As for the rest of them, I don’t know for sure. But they all involve specific fields and would only run when those fields are needed. I do know that validate attachment runs before update_value and that validate_value runs before update_value, but this only happens if for some reason the form did not validate during the AJAX request. validate_value also runs on each field during the AJAX validation request when no values are saved.

    Not sure this helped you at all or why you’re looking for the information. I have the vague cloud in my head of the order that things happen in WP and most of the actions/filters in ACF are tied to WP filters.

    This looks interesting https://wordpress.stackexchange.com/questions/162862/how-to-get-wordpress-hook-run-sequence/162863.

  • Thanks very much. I just like flow charts and to know how things work and in what order.

    I am working on a fairly large and complex project and this helps me to visualize the things I need to do and when they get done.

  • That Query Monitor plugin was just the trick!

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Form Processing Hook Chart’ is closed to new replies.