Summer Sale: Save 20% on any WS Form edition CODE: SUMMER20 View Pricing
WordPress Hooks
Built-In

WordPress Hooks

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

How to Use Hooks with Forms in WordPress

Add custom WordPress hook logic to your form workflow

Use the Run WordPress Hook action to run a WordPress action or filter when a user saves or submits a form. This gives developers a flexible way to run custom PHP code from a WordPress form workflow.

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

When using a filter, WS Form passes the form and submit objects to your hook. Your filter can return an updated submit object, a spam level from 0 to 100, an array for messages, field value changes, or redirects, or a value that halts further action processing.

Action hooks also receive the form and submit data, making it possible to retrieve submitted field values and process them in your own PHP code.

  • Run on save or submit

    Choose to run the hook when the form is saved, submitted, or both.

  • Use actions or filters

    Run either a WordPress action or filter and pass form and submit data into your PHP code.

  • Control hook timing

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

Real Customer Reviews

Trusted by thousands of WordPress professionals.

  • WS Form has a comprehensive, powerful feature set and is nevertheless user friendly. Overall, an extremely impressive plugin with excellent support.

    Roger M. Hall
  • The best plugin ever and amazing support. The best team ever.

    kouroshrg
  • We use WS Form across all our client sites as it is simply the best WordPress form plugin out there.

Frequently Asked Questions

How do I integrate WordPress with WordPress Hooks using WS Form?

Add the Run WordPress Hook action to your form, choose when it should run, select a hook type, enter the hook tag, and save your changes. For full setup details, see Run WordPress Hook.

When can the Run WordPress Hook action run?

It can run when the form is saved, submitted, or both.

What hook types are supported?

You can run either a filter using apply_filters or an action using do_action.

What data is passed to a WordPress 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 an updated submit object, an integer from 0 to 100 for spam level, an array for messages, field value changes or redirects, or a value that halts further action processing.

Can a filter set field values?

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

Can a filter return a message or redirect?

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

Get This Integration

View Editions →

Built into WS Form PRO and available with every PRO edition.