Skip to content
  • Why WPGetAPI?
  • Examples
  • Pricing
  • Plugins
    • PRO Plugin
    • API to Posts Plugin
    • OAuth 2.0 Plugin
  • Docs
  • Support
    • Frequently Asked Questions
    • Feature Request
    • Support Ticket
  • account_circle
PRO Plugin
Howdy! How can we help you?
  • Introduction

    • Quick Start
    • Frequently Asked Questions
    • Will this work with my API?
    • Understanding API docs
    • Step by Step Example
  • Setup

    • Setup Page
    • Endpoint Page
    • Parameters - Query String
    • Parameters - Headers
    • Parameters - Body POST
    • Shortcode
    • Template Tag
    • Gutenberg Block
  • Connecting your API

    • API Key in Headers
    • API Key in Query String
    • Authentication & Authorization
  • Output API Data

    • Format API to HTML
    • Format API to HTML Table
    • Format API to Image Gallery
    • Format JSON Data
  • Integrations

    • Send form data to API
    • WPForms to API
    • Gravity Forms to API
    • Contact Form 7 to API
    • WooCommerce to API
    • WooCommerce API Product Sync
    • wpDataTables to API
    • Connect WordPress to OpenAI
    • Connect RapidAPI to WordPress
    • Connect Zoho CRM to WordPress
    • Page Builders (Elementor, DIVI)
    • Formidable Forms to API
    • Elementor Form to API
    • JetFormBuilder to API
    • Fluent Forms to API
    • WS Form to API
    • Ninja Tables to API
    • Easy Digital Downloads(EDD) API Product Sync
    • Ultimate Member Forms to API
  • Tips & Tricks

    • Filters & Action Hooks
    • Code Snippets Plugin
    • Troubleshooting
    • Code Snippets
  • PRO Plugin

    • Installation
    • Actions
    • Tokens
    • Caching
    • Nested data
    • Chaining API calls
    • Dynamic Variables
    • Format API to HTML
    • Call API on user registration
    • Using AJAX to trigger API call
    • Base64 Encoding
    • Licensing
    • Filters & Action Hooks
  • OAuth 2.0 Plugin

    • Installation
    • How it works
    • Grant Type - Client Credentials
    • Grant Type - Authorization Code
    • Licensing
  • API to Posts Plugin

    • Installation
    • Getting Started
    • Multiple Endpoints
    • Mapping Fields
    • Filters & Action Hooks
    • Pagination

PRO Plugin – Filters & Action Hooks

These actions and filters help extend or modify the functionality of the PRO plugin. Code snippets would need to be added to your themes functions.php file.


Filter: wpgetapi_query_variables_delimiter

This filter allows you to modify the delimiter when using the query_variables option as shown here. The default delimiter is a comma but sometimes commas are accepted within a query string.

function wpgetapi_modify_delimiter( $delimiter ) {
    // set the delimiter to whatever you like
    return '&';
}
add_filter( 'wpgetapi_query_variables_delimiter', 'wpgetapi_modify_delimiter', 10, 1 );

Filter: wpgetapi_line_items_wrapper

This filter allows you to modify how each line item is wrapped when using the (line_items) token as shown here. The default wrapper looks like this: {value},

The example below will remove the curly braces.

function wpgetapi_modify_line_items_wrapper( $value ) {
    $value = str_replace( '{', '', $value );
    $value = str_replace( '}', '', $value );
    return $value;
}
add_filter( 'wpgetapi_line_items_wrapper', 'wpgetapi_modify_line_items_wrapper', 10, 1 );

Filter: wpgetapi_query_variables_explode_separator

This filter allows you to modify the explode separator when using the query_variables option as shown here. The default delimiter is an equals sign = but sometimes this may need to be changed.

function wpgetapi_modify_explode_separator( $separator ) {
    // set the separator to whatever you like
    return '~';
}
add_filter( 'wpgetapi_query_variables_explode_separator', 'wpgetapi_modify_explode_separator', 10, 1 );

Filter: wpgetapi_argument_values_before_{$action}

This filter allows us to modify a value from an Action before it is sent to the API. The {$action} is the name of the action being run, which can be found in the Actions Log.

In this example we have the Action set to WooCommerce – New Order Created. So looking below at the code, we can see that the {$action} has been set as: wpgetapi_argument_values_before_woocommerce_new_order. This means that this code will only execute when a new WooCommerce order is created.

The code below is modify the value of ‘number’ and also rounding each of the line item subtotals to 2 decimal points.

function wpgetapi_modify_action_values( $args, $endpoint ) {
    
    // remove INT- from 'number'
    if( isset( $args['number'] ) )
        $args['number'] = str_replace('INT-', '', $args['number'] );
 
    // round each line item subtotal
    if( isset( $args['line_items'] ) ) {
        foreach ( $args['line_items'] as $i => $line_item ) {
            if( isset( $line_item['subtotal'] ) )
                $args['line_items'][ $i ]['subtotal'] = round( $line_item['subtotal'], 2 );
        }
    }
 
    return $args;
}
add_filter( 'wpgetapi_argument_values_before_woocommerce_new_order', 'wpgetapi_modify_action_values', 10, 2 );

Action: wpgetapi_after_{$action}

This filter runs immediately after a WPGetAPI Action is run. Actions are set within the admin as shown below. The {$action} is the name of the action being run, which can be found in the Actions Log.

In this example we have the Action set to call the API whenever the Gravity Forms – Lead Capture Form is filled in. The ID of this form is #8. So looking below at the code, we can see that action is: wpgetapi_after_gravity_forms_8. This means that this code will only execute when this form is submitted.

We are using the response code of the API call to then redirect based on this response code.

function wpgetapi_redirect_after_response( $result, $argument_values, $values_sent, $endpoint, $response_code ) {

    // if successful 200 response, do a redirect
    if( $response_code == 200 ) {
        
        $url = home_url( '/confirmation' );
        wp_redirect( $url );
        exit;

    }

    // if failed 404 response, do a redirect
    if( $response_code == 404 ) {
        
        $url = home_url( '/error' );
        wp_redirect( $url );
        exit;

    }

}
add_action( 'wpgetapi_after_gravity_forms_8', 'wpgetapi_redirect_after_response', 10, 5 );
On this page

Unlock amazing features with the PRO Plugin

The PRO Plugin takes your API integrations to the next level.

  View Pro Plugin
contact_support

Still not sure?

APIs can be daunting and sometimes downright confusing.

But we are here to help! Our support is amazing and we can assist you with any setup required and ensure your API integrations are a success!

Ask Us Anything

Connect your WordPress website to external APIs without writing a single line of code. Send data from WordPress to your API or display data from your API within WordPress.

Support

  • Documentation
  • Support Ticket
  • Refund Policy
  • Contact Us
  • About Us
  • Affiliates

Articles

  • Quick Start Guide
  • WooCommerce Orders to API
  • WooCommerce API Products Sync
  • Contact Form 7 to API
  • WPForms to API
  • Gravity Forms to API
  • WordPress to RapidAPI

WordPress API Plugins

  • Free WPGetAPI Plugin
  • PRO Plugin
  • API to Posts Plugin Plugin
  • OAuth 2.0 Authorization Plugin

© 2025 WPGetAPI. All Rights Reserved.

"*" indicates required fields

Name*
This field is for validation purposes and should be left unchanged.