This site is automated with plugin and protected with WP Cerber security plugin

Newsletter Subscription

If you want to subscribe to our monthly newsletter, please submit the form below.


Using workflow as WordPress filter > Documentation  > Using workflow as WordPress filter

Using workflow as WordPress filter

Yes, you can rapidly create native WordPress filters by using workflows. Workflows, created by using plugin are extremely fast and the filter can be made in a few minutes without coding and having knowledge of PHP. You will get your new filter instantly having created and enabled the workflow.

Read documentation carefully before you start creating filters.

Firstly, a small quote from the WordPress documentation:

Filters are functions that WordPress passes data through, at certain points in execution, just before taking some action with the data (such as adding it to the database or sending it to the browser screen). Filters sit between the database and the browser (when WordPress is generating pages), and between the browser and the database (when WordPress is adding new posts and comments to the database); most input and output in WordPress passes through at least one filter. WordPress does some filtering by default, and your plugin can add its own filtering.

Let’s create the filter

To get any workflow working as a WordPress filter, you have to define, at least, two items in the workflow.

First item is a hook name that you have to set up by using the Hook up trigger. Second item is the Return it action that you need to put at the end of the workflow. Both items are mandatory for filters, otherwise you will get unpredictable result that might even broke functionality of your site completely.

So, you have to start workflow with Hook up and finish it with Return it. Optionally, you can use action Stop if somewhere in the middle of your workflow and return value back to WordPress.

Trigger: Hook up

This trigger register the workflow with WordPress hook system. The name of the filter hook is provided by WordPress or third-party plugin or a theme. Hook defines when the workflow should be started and the filter should be applied.

Note: You can not use any WordPress hook (filter or action) that occurred earlier than init action.

How can you get value passed by WordPress to the workflow? Use pattern {TRIGGER}. This pattern are represent a value that WordPress is expecting your workflow will process. Additional parameters passed by WordPress can be gotten respectively with {ARG[1]}, {ARG[2]} and so on. To figure out what parameters will be passed read documentation on particular hook you want to use. Read documentation on the Hook up trigger.

Action: Return it

You have to use this action at the end of the workflow. It immediately ends execution of the current workflow and return value back to WordPress. To return unchanged value use pattern {ARG[0]} or {TRIGGER} in this field.

Set up returning value according to description of the filter hook. Read documentation on the Return it action.

Action: Stop if

Sometimes you might need to apply filter conditionally. That is not a problem and you can configure as many conditions as you need. You just need to remember that in spite of any set of any conditions you have to return value back to WordPress. You have to use the Stop if action and specify returning value with a field Return value. To return unchanged value use pattern {ARG[0]} or {TRIGGER} in that field.

Set up returning value according to description of the filter hook. Read documentation on the Stop if action.

Note: Some type of filters can’t be created due to complexity of data passed by WordPress. Make sure that you pass right type of data you have to pass back to WordPress.

Read some documentation about WordPress filters:


No Comments

Sorry, the comment form is closed at this time.