1. Home
  2. For Devs
  3. Filter
  4. Filter webhook trigger data
  1. Home
  2. Plugins
  3. WP Webhooks
  4. For Devs
  5. Filter
  6. Filter webhook trigger data

Filter webhook trigger data


This filter allows you to manipulate the webhook data that will be send to a certain webhook.

Parameter Type Description
$data array

An array of the currently set data that will be later on the webhook payload.

$response array

An array of the settings if the trigger is valid or not (based on its settings).

$webhook array

The webhook data as it comes from our plugin.

$args array

Custom set http arguments that will be used for performing the wp_safe_remote_request function

$authentication_data array

An array containing the authentication type as auth_type and the authentication data array as data

$data = apply_filters( 'wpwhpro/admin/webhooks/webhook_data', $data, $response, $webhook, $args, $authentication_data );

Example callback

The example down below will allow you to manipulate the data that is sent by the post_updated trigger and only for the added webhook URL my-url-name.
You can customize them with the variables down below.
In our example, we simply add a new key to the payload called new_key with the value “This is some new data“.

add_filter( 'wpwhpro/admin/webhooks/webhook_data', 'wpwh_manipulate_outgoing_webhook_data', 20, 5 );
function wpwh_manipulate_outgoing_webhook_data( $data, $response, $webhook, $args, $authentication_data ){

    $webhook_name = 'post_updated'; //set this to your chosen trigger endpoint
    $webhook_url_name = 'my-url-name'; //set this to your chosen webhook URL name
    $inc_webhook_name = ( is_array($webhook) && isset( $webhook['webhook_name'] ) ) ? $webhook['webhook_name'] : '';
    $inc_webhook_url_name = ( is_array($webhook) && isset( $webhook['webhook_url_name'] ) ) ? $webhook['webhook_url_name'] : '';

    if( $webhook_name !== $inc_webhook_name || $webhook_url_name !== $inc_webhook_url_name ){
        return $data;

    //Customize your data construct here
    // This is an array in most cased, but can be mixed
    if( is_array( $data ) ){
        $data['new_key'] = 'This is some new data';

    return $data;
Updated on January 15, 2022

Was this article helpful?

Related Articles