---
title: "Code Glue"
description: "Attach short PHP snippets per webhook+trigger to enrich payloads before dispatch."
url: "https://wpwebhooks.org/docs/code-glue/"
---

[WP Webhooks](https://wpwebhooks.org/) / [Docs](https://wpwebhooks.org/docs/) / Code Glue

Feature Pro since v1.7.0

# Code Glue

Attach short PHP snippets per webhook+trigger to enrich payloads before dispatch.

Write a pre-dispatch PHP snippet in the admin panel and attach it to a webhook+trigger combination. The snippet runs after payload mapping and can read WordPress data, look up post meta, call internal functions, or reshape fields without touching theme or plugin files.

## Available variables

`$payload` — the mapped payload array. `$args` — shortcut to `$payload['args']`, the original hook arguments.

## Shorthand syntax

Curly-brace placeholders resolve to array access for any variable: `{{ $args.0.field }}` → `$args[0]['field']`, `{{ $payload.key }}` → `$payload['key']`.

## Return value

Must `return $payload;` — the returned array replaces the payload before dispatch.

/ Examples

Look up and inject a HubSpot deal ID from post meta

```
// Available: $payload (mapped array), $args ($payload['args'])
$order_id = $payload['order_id'] ?? 0;
$hs_deal_id = get_post_meta( $order_id, '_hs_deal_id', true );
$payload['hs_deal_id'] = $hs_deal_id;
return $payload;
```

/ Related

[Post-Dispatch Scripting](https://wpwebhooks.org/docs/post-dispatch-scripting/)[Payload Mapping](https://wpwebhooks.org/docs/payload-mapping/)[fswa\_webhook\_payload](https://wpwebhooks.org/docs/fswa-webhook-payload/)

/Ready

## Your next automation is  
one sentence away.

[Install Plugin→](https://wordpress.org/plugins/flowsystems-webhook-actions/) [See the Plugin →](https://wpwebhooks.org/wordpress-webhook-plugin/)

$ wp plugin install flowsystems-webhook-actions --activate

## Structured data

```json
{"@context":"https://schema.org","@type":"TechArticle","name":"Code Glue — Feature — Webhook Actions Docs","description":"Attach short PHP snippets per webhook+trigger to enrich payloads before dispatch.","url":"https://wpwebhooks.org/docs/code-glue/","isPartOf":{"@type":"WebSite","name":"WP Webhooks","url":"https://wpwebhooks.org"},"about":{"@type":"SoftwareApplication","name":"Webhook Actions","applicationCategory":"WordPress Plugin"}}
```
