Run WordPress Hooks When Forms Are Saved or Submitted in WordPress

Run WordPress actions or filters when a form is saved, submitted, or both.

  • Run on save or submit Choose to run the hook when the form is saved, submitted, or both.
  • Use filters or actions Select either a WordPress filter or action for your form workflow.
  • Choose the hook tag Enter the tag name of the filter or action you want to run.
  • Control hook priority Run the hook before submission creation, before other actions, or after other actions.
  • Access form and submit Both filters and actions receive form and submit data.
  • Return useful outcomes Filters can return updated submit data, messages, redirects, spam levels, or halt processing.

The Run WordPress Hook action lets you run a WordPress action or filter when a user saves or submits a form. It gives developers a way to run PHP code from a form workflow in WordPress.

You can choose whether the hook runs on save, submit, or both. You can also select a filter or action, enter the hook tag, and choose whether it runs before submission creation, before other actions, or after other actions.

When used as a filter, the hook can return updated submit data, a spam level, custom messages, error messages, redirects, or a halt signal for action processing. When used as an action, the hook receives the form and submit data so you can work with submitted values in your own code.

Learn how to use the Run WordPress Hook action.

  • Developer-friendly automation

    Run your own PHP code when a website visitor saves or submits a form.

  • Flexible trigger timing

    Choose whether the hook runs on save, submit, or both to match your workflow.

  • Filter or action support

    Use a filter with apply_filters or an action with do_action.

  • Before or after actions

    Set the hook to run before submission creation, before other actions, or after other actions.

  • Update submit data

    A filter can return a submit object that is passed to the next action.

  • Set field values

    A filter can return an array to set a field value, including options for append, prepend, and repeatable section targeting.

  • Show messages or redirect

    A filter can return custom messages, error messages, or a redirect URL.

  • Support spam workflows

    A filter can return an integer from 0 to 100 to set the spam level.

Real Customer Reviews

Trusted by thousands of WordPress professionals.

  • Kudos and compliments to the team and a big thank you from Haritomedia!!!

    haritomedia
  • Does everything you would want it to do and so much more. Support is outstanding.

    ycits
  • You'll be hard-pressed to find a more flexible professional and complete form building solution for WordPress.

    Casey Strouse

Frequently Asked Questions

What does the Run WordPress Hook action do?

It runs a WordPress action or filter when a user saves or submits a form.

When can this action run?

You can choose to run the hook when the form is saved, submitted, or both.

What hook types are supported?

You can select either a filter or an action.

What data is passed to the hook?

Both filters and actions receive the form and submit data. For filters, WS Form calls apply_filters($tag_name, $form, $submit). For actions, WS Form calls do_action($tag_name, $form, $submit).

What can a filter return?

A filter can return a submit object, an integer from 0 to 100 for spam level, an array for messages, field value changes or redirects, or a halt signal for action processing.

Can I change field values with this action?

Yes. A filter can return an array with a field_value action to set a field value. The available parameters include field_id, value, check, append, prepend, and section_repeatable_index.

Can I show a message or redirect after the hook runs?

Yes. A filter can return an array for a custom message, an error message, or a redirect URL.

How do I run WordPress hooks on save or submit in WS Form?

Edit your form, open the Actions sidebar, add a new action, and select Run WordPress Hook. Then choose when it should run, select the hook type, enter the hook tag, and save your changes. You can also follow the full guide here.