Freeform Freeform for Craft

Developer

Post Forwarding

Modify the POST payload

Use this event to add/remove things to the posted payload or make modifications to the Guzzle Client and Request objects.

use Solspace\Freeform\Events\PostForwarding\PostForwardingEvent;
use Solspace\Freeform\Integrations\Single\PostForwarding\PostForwarding;

Event::on(
    PostForwarding::class,
    PostForwarding::EVENT_POST_FORWARDING,
    function (PostForwardingEvent $event) {
        // Get the existing payload
        $payload = $event->getPayload();

        // Add something to it
        $payload['addedThing'] = 'This is an added thing';
        
        // Remove several of the default items from it
        unset(
            $payload['submission-id'], 
            $payload['submission-token'],
            $payload['submission-title']
        );

        // Persist our new changes in the event
        $event->setPayload($payload);
    }
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24