1. Home
  2. Docs
  3. Packages
  4. WordPress Hooks Package

WordPress Hooks Package

This package is designed to empower you with the ability to define callbacks in the Convoworks editor for WordPress filters and actions.

Check out our examples Building a NoCode Spam Filter with Convoworks, GPT, and WordPress and Beyond Coding: API Synchronization with WordPress

Setting Up WordPress Hooks

Whether you're creating a new Convoworks service or utilizing an existing one, you can seamlessly integrate the convo-wp-hooks package. After you've enabled it in the workflow editor, you can begin using WordPress hooks related components.

Alternatively, you can start new service and chose the “WordPress Hooks Project” template. This template hooks to the “the_title” filter and will make your post titles ucwords.

To activate hook handling, there's one more simple step. Navigate to the Configuration view and toggle on the WordPress Hooks platform.

The Special role option can be left blank. In this scenario, the service will execute the first step (typically Home or Session Start).

However, if you're integrating WordPress Hooks with another platform and your Home step is already occupied, you can designate WordPress Hooks as a Special role request. To do so, add a Special Role Processor Block to your service, which can be found under the Add new block dropdown. Next, assign the block's role the same value you outlined in your configuration.

Limitations, Behavior, and Performance

Since the Convoworks WP is loaded through the init WordPress action, init is the earliest hook you can manage.

Convoworks stores registered hooks in WordPress options (convoworks_hooks_handler) and uses that information to decide whether or not to load the service. This ensures that if not activated, Convoworks won't impact your website's performance.
Each time you modify your service hook definition (like the hook name or priority), the data in the options will be automatically updated.

In the event of an error during your WordPress hooks handling service, it will be safely caught, and your system will operate as if Convoworks was not present. To view potential errors, you'll need to enable the WordPress debug log.

Service template with the example

Check in the video below how you can quickly setup and try WordPress Hooks package.

Available Functions and Components

During the hook execution, there are several specific methods you can use on the request object

  • ${request.getHook()} returns activated hook name
  • ${request.getArguments()} returns callback function arguments as array
  • ${request.getArgument( index)} returns callback function argument at given index (starts with 0)

Currently available WordPress functions in this package:

  • register_post_type()link
  • is_home()link
  • is_admin()link
  • register_sidebar()link
  • remove_filter()link
  • remove_action()link
  • wp_redirect()link
  • do_shortcode()link
  • add_rewrite_rule()link
  • wp_unschedule_event()link
  • wp_schedule_event()link
  • wp_next_scheduled()link

For more available WordPress functions check our Core WordPress package and for other PHP functions our Core package.

Components

  • WP Hook Processor: Use this processor to specify the hook you want to activate. When your chosen hook is triggered, the elements in the OK flow will be executed. This component can handle both actions and filters. For filter hooks, utilize the WP Filter Result element to return your filter modified value. If you neglect to do this, the system will default to returning the original, unaltered value.

  • WP Filter Result: This element concludes the execution and returns the filter value.

  • Echo Element: This element will print out given text

  • Exit Element: This element will stop execution